An MCP server exposes operations to AI applications through a standard interface. It publishes tool names, descriptions, and input schemas so an MCP client can discover and invoke them. The server executes each tool and returns its result. It does not replace an API or database: a tool can call either internally, without requiring every client to implement that integration. section 9.6
The host is the application the user interacts with; it manages clients that communicate with servers. A server can use stdio to communicate with a process on the same machine or HTTP for a remote connection. Publishing a tool does not decide when to call it—that remains the host agent’s responsibility. section 9.6.1 section 9.6.3
To expose existing Python operations with FastMCP:
- Create a named FastMCP server and the backend that performs the work. section 9.6.2
- Decorate small wrapper functions with @mcp.tool(). Their names, docstrings, type hints, and defaults form the definitions clients discover; clear descriptions and parameter types help an agent choose tools and supply valid arguments. section 9.6.2
- Call mcp.run() to start the server. A client then initializes an MCP session, lists the tools, and invokes selected tools through that session. section 9.6.2 section 9.6.3
Knowledge-base tools for a support agent
A server exposes search_wix_kb, which returns matching article IDs and snippets, and read_wix_kb_article, which accepts an ID and returns the complete article. A DSPy client discovers both at runtime, converts them with dspy.Tool.from_mcp_tool(), and supplies them to ReAct. When ReAct chooses a tool, it runs in the server process rather than the agent process; its result returns as an observation. section 9.6.2 section 9.6.3
Tools loaded into the DSPy ReAct agent:
- search_wix_kb, whose description is <desc>Search Wix knowledge-base article titles and return relevant IDs and snippets.</desc>. It takes arguments {'query': {'title': 'Query', 'type': 'string'}, 'limit': {'default': 5, 'title': 'Limit', 'type': 'integer'}}.
- read_wix_kb_article, whose description is <desc>Read a complete Wix knowledge-base article using an ID returned by search_wix_kb.</desc>. It takes arguments {'article_id': {'title': 'Article Id', 'type': 'integer'}}.
- finish, whose description is <desc>Marks the task as complete. That is, signals that all information for producing the outputs, i.e. 'answer', are now available to be extracted.</desc>. It takes arguments {}.
Trajectory:
tool_name_0: search_wix_kb
tool_name_1: read_wix_kb_article
tool_name_2: finish
The discovered schemas and trajectory show the agent searching first, then reading an article by ID. section 9.6.3











