DirectClient is ideal for SDK integrations, unit testing, AI agent frameworks (LangChain, Vercel AI), and same-process embeddings where network overhead is undesirable.
Transport Comparison
FrontMCP supports multiple ways to connect to MCP servers. Choose based on your use case:| Aspect | DirectClient | Stdio | HTTP (Streamable) |
|---|---|---|---|
| Use Case | SDK access, testing, same-process | CLI tools, desktop clients | Remote servers, web apps |
| Connection | In-process (no network) | Stdin/stdout pipes | HTTP/HTTPS requests |
| Process Model | Same process | Separate process | Separate server |
| Latency | Lowest | Low (IPC overhead) | Higher (network) |
| Session State | In-memory | Per-process | Persistent (Redis) |
| Auth | Direct token injection | Environment-based | Bearer tokens, OAuth |
| Best For | Agent frameworks, tests | Claude Desktop, Cursor | Production APIs |
When to Use DirectClient
- Building AI agents: Integrate MCP tools directly into LangChain, Vercel AI, or custom agent code
- Testing: Write unit/integration tests without spinning up servers
- Same-process integrations: Embed MCP capabilities in your application
- Performance-critical: Avoid network/IPC overhead for high-throughput scenarios
When to Use Stdio
- Desktop MCP clients: Claude Desktop, Cursor, VS Code extensions
- CLI tools: Command-line interfaces that spawn MCP servers
- Local development: Quick testing with standard MCP clients
When to Use HTTP Transport
- Production deployments: Remote servers, load balancing, scaling
- Web applications: Browser-based clients, REST-like access
- Multi-tenant systems: Shared servers with authentication
- Distributed architectures: Microservices, serverless
Quick Start
Basic Connection
LLM-Specific Connections
For automatic tool/result formatting based on LLM platform:Core Operations
Tool Operations
Resource Operations
Prompt Operations
Skills Operations
Skills are modular knowledge packages that teach AI how to perform multi-step tasks.Search Skills
Load Skills
List Skills
Elicitation Handling
Elicitation allows tools to request user input during execution. DirectClient can handle these requests programmatically.Register Handler
Manual Submission
For async or external elicitation handling:Completion Operations
Request argument completion for prompts or resources:Resource Subscriptions
Subscribe to resource updates for real-time notifications:Logging Control
Set server-side logging level:Connection Options
Info Methods
Platform-Specific Formatting
DirectClient automatically formats tools and results based on the detected platform:| Platform | Tool Format | Result Format |
|---|---|---|
| OpenAI | { type: 'function', function: {...} } | Parsed JSON or string |
| Claude | { name, description, input_schema } | Content array |
| LangChain | { name, description, schema } | Parsed JSON |
| Vercel AI | { [name]: { description, parameters } } | Parsed JSON |
| Raw | MCP native format | MCP CallToolResult |
Error Handling
Type Exports
All types are exported from@frontmcp/sdk/direct:
Best Practices
Always close the client
Always close the client
Use LLM-specific helpers
Use LLM-specific helpers
Use
connectOpenAI, connectClaude, etc. for automatic response formatting instead of manual conversion.Handle elicitation for interactive tools
Handle elicitation for interactive tools
Register an
onElicitation handler if your tools use this.elicit() for user input.Check capabilities before using optional features
Check capabilities before using optional features