API Reference
This page documents the public Python API exposed by deepmcpagent.
Public API for deepmcpagent.
ServerSpec = StdioServerSpec | HTTPServerSpec
module-attribute
Union of supported server specifications.
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
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
client
property
Return the underlying FastMCP client instance.
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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
MCPToolLoader
Discover MCP tools via FastMCP and convert them to LangChain tools.
Source code in src/deepmcpagent/tools.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
get_all_tools()
async
Return all available tools as LangChain BaseTool instances.
Source code in src/deepmcpagent/tools.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
list_tool_info()
async
Return human-readable tool metadata for introspection or debugging.
Source code in src/deepmcpagent/tools.py
188 189 190 191 192 193 194 195 196 197 198 199 | |
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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
ToolInfo
dataclass
Human-friendly metadata for a discovered MCP tool.
Source code in src/deepmcpagent/tools.py
22 23 24 25 26 27 28 29 | |
build_deep_agent(*, servers, model, instructions=None, trace_tools=False, cross_agents=None)
async
Build an MCP-first 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
|
str | None
|
Optional system prompt. If not provided, uses DEFAULT_SYSTEM_PROMPT. |
None
|
trace_tools
|
bool
|
If True, print each tool invocation and result from inside the tool wrapper (works for both DeepAgents and LangGraph prebuilt). |
False
|
cross_agents
|
Mapping[str, CrossAgent] | None
|
Optional mapping of peer name -> CrossAgent. When provided, each
peer is exposed as a tool (e.g., |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Runnable[Any, Any], MCPToolLoader]
|
Tuple of |
Source code in src/deepmcpagent/agent.py
33 34 35 36 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 79 80 81 82 83 84 85 86 87 88 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
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
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 91 | |