API Reference
Typed server specifications and conversion helpers for FastMCP configuration.
ServerSpec = Union[StdioServerSpec, HTTPServerSpec]
module-attribute
Union of supported server specifications.
HTTPServerSpec
Bases: _BaseServer
Specification for a remote MCP server reachable via HTTP/SSE.
Attributes:
Name | Type | Description |
---|---|---|
url |
str
|
Full endpoint URL for the MCP server (e.g., http://127.0.0.1:8000/mcp). |
transport |
Literal['http', 'streamable-http', 'sse']
|
The transport mechanism ("http", "streamable-http", or "sse"). |
headers |
Dict[str, str]
|
Optional request headers (e.g., Authorization tokens). |
auth |
str | None
|
Optional auth hint if your FastMCP deployment consumes it. |
Source code in src/deepmcpagent/config.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
StdioServerSpec
Bases: _BaseServer
Specification for a local MCP server launched via stdio.
NOTE
The FastMCP Python client typically expects HTTP/SSE transports. Using
StdioServerSpec
requires a different adapter or an HTTP shim in front
of the stdio server. Keep this for future expansion or custom runners.
Attributes:
Name | Type | Description |
---|---|---|
command |
str
|
Executable to launch (e.g., "python"). |
args |
List[str]
|
Positional arguments for the process. |
env |
Dict[str, str]
|
Environment variables to set for the process. |
cwd |
str | None
|
Optional working directory. |
keep_alive |
bool
|
Whether the client should try to keep a persistent session. |
Source code in src/deepmcpagent/config.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
servers_to_mcp_config(servers)
Convert programmatic server specs to the FastMCP configuration dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
servers
|
Mapping[str, ServerSpec]
|
Mapping of server name to specification. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Dict[str, object]]
|
Dict suitable for initializing |
Source code in src/deepmcpagent/config.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
FastMCP client wrapper that supports multiple servers via a single configuration.
FastMCPMulti
Create a single FastMCP client wired to multiple servers.
The client is configured using the mcpServers
dictionary generated from
the typed server specifications.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
servers
|
Mapping[str, ServerSpec]
|
Mapping of server name to server spec. |
required |
Source code in src/deepmcpagent/clients.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
client
property
Return the underlying FastMCP client instance.
MCP tool discovery and conversion to LangChain tools.
MCPToolLoader
Discover MCP tools via FastMCP and convert them to LangChain tools.
Source code in src/deepmcpagent/tools.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
get_all_tools()
async
Return all available tools as LangChain BaseTool
instances.
Source code in src/deepmcpagent/tools.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
list_tool_info()
async
Return human-readable tool metadata for introspection or debugging.
Source code in src/deepmcpagent/tools.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
ToolInfo
dataclass
Human-friendly metadata for a discovered MCP tool.
Source code in src/deepmcpagent/tools.py
14 15 16 17 18 19 20 |
|
System prompt definition for deepmcpagent.
Edit this file to change the default system behavior of the agent without modifying code in the builder.
Agent builders that use the FastMCP client and MCP-only tools.
build_deep_agent(*, servers, model, instructions=None)
async
Build an MCP-only agent graph.
This function discovers tools from the configured MCP servers, converts them into
LangChain tools, and then builds an agent. If the optional deepagents
package is
installed, a Deep Agent loop is created. Otherwise, a LangGraph ReAct agent is used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
servers
|
Mapping[str, ServerSpec]
|
Mapping of server name to spec (HTTP/SSE recommended for FastMCP). |
required |
model
|
ModelLike
|
REQUIRED. Either a LangChain chat model instance, a provider id string
accepted by |
required |
instructions
|
Optional[str]
|
Optional system prompt. If not provided, uses DEFAULT_SYSTEM_PROMPT. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Runnable, MCPToolLoader]
|
Tuple of |
Source code in src/deepmcpagent/agent.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|