Connectors and MCP
Build connector catalogs, expose connector instances as tools, consume remote MCP servers, and bridge connected integrations back out through MCP in @namzu/sdk.
@namzu/sdk publishes a real interoperability surface beyond providers and tools. The connector layer manages long-lived external integrations inside Namzu, and the MCP layer adapts tool or resource surfaces across process boundaries.
1. The Mental Model
These surfaces are related, but they solve different problems:
| Surface | Owns | Main exports |
|---|---|---|
| Provider | model calls | ProviderRegistry, LLMProvider |
| Tool | model-callable action | defineTool, ToolRegistry |
| Connector | reusable external integration with lifecycle | ConnectorRegistry, ConnectorManager, HttpConnector, WebhookConnector |
| MCP client | consume remote MCP tools and resources | MCPClient, MCPToolDiscovery, mcpToolToToolDefinition |
| MCP bridge/server | publish Namzu capabilities to MCP consumers | MCPConnectorBridge, MCPServer, toolDefinitionToMCPTool |
Rule of thumb:
- use connectors when Namzu owns the integration lifecycle
- use MCP when the integration already speaks MCP or must be published to MCP consumers
2. Register Connector Definitions Once
The connector registry stores definitions, not live connections:
This is application bootstrap work. Do it once, then create live instances from those definitions as runtime config becomes available.
3. Create and Connect Instances
ConnectorManager owns the live lifecycle:
Important boundaries:
ConnectorRegistryknows definitionsConnectorManagerknows live instances and connection state- the concrete connector object performs the actual external I/O
4. Execute Connector Methods Directly
You can call connected instances without going through the tool system:
This is useful for:
- diagnostics
- admin backends
- boot-time validation before tools are exposed to a model
5. Expose Connectors as Namzu Tools
Once a connector is connected, you can adapt it into standard Namzu tools:
Two patterns exist:
| Pattern | When it fits |
|---|---|
createConnectorTools({ manager }) | You want a small stable tool surface that routes by instance ID and method name |
allConnectorTools(manager) | You want one concrete tool per connected method |
If you want one explicit router-style tool, use createConnectorRouterTool() or ConnectorToolRouter.
6. Consume Remote MCP Servers Inside Namzu
Use MCPClient when a remote server already speaks MCP and should show up as Namzu tools:
The generated tool names are prefixed as:
mcp_<serverName>_<toolName>
That keeps remote MCP tools distinct from local tool definitions.
7. Read MCP Resources and Templates
The MCP client surface is broader than tools:
This is useful when a remote MCP server exposes documents, datasets, or templated resource URIs alongside tool calls.
8. Available MCP Transport Shapes
The current SDK exports two client transport shapes:
| Transport | Use it when... |
|---|---|
stdio | The MCP server is a child process you spawn locally |
http-sse | The MCP server is reachable over an HTTP-plus-SSE endpoint |
Typical http-sse config shape:
9. Publish Connected Connectors Back Out Through MCP
MCPConnectorBridge turns connected connector methods into MCP tool definitions:
Important limitation to understand clearly:
MCPServerneeds anMCPTransportimplementation that accepts inbound MCP traffic- the SDK currently ships outbound client transports (
StdioTransportandHttpSseTransport) - in practice, server hosting usually happens inside an app shell, framework adapter, or plugin runtime that already owns the transport layer
So the bridge and server are publishable building blocks, but your host process still decides how inbound MCP traffic reaches them.
10. Conversion Helpers
The SDK also exports direct conversion helpers:
| Helper | Purpose |
|---|---|
mcpToolToToolDefinition() | Turn a remote MCP tool into a Namzu tool |
toolDefinitionToMCPTool() | Turn a Namzu tool into an MCP tool definition |
mcpToolResultToToolResult() | Normalize remote MCP tool results into Namzu ToolResult |
toolResultToMCPToolResult() | Convert Namzu tool results back into MCP result blocks |
Use these when you need custom adaptation logic rather than the higher-level discovery or bridge helpers.
11. Connector and MCP Patterns That Scale Well
For production usage:
- register connector definitions once at app startup
- create connector instances from tenant, project, or environment config
- connect and health-check them before exposing tools
- use generic connector tools for dynamic environments
- use per-method tools only when the surface is narrow and stable
- use
MCPClientwhen the integration already ships as MCP - use
MCPConnectorBridgeonly after connector instances are connected
That keeps lifecycle ownership explicit instead of mixing definitions, connection state, and tool exposure into one abstraction.