Lesson 16 / 25
Using MCP Tools in Your Own Agent
Understand how an application lists a server's tools and forwards calls from the model.
The client's job
When you build your own host, your MCP client does three things: connect to the server, call tools/list to get the tool definitions, and forward each model-requested call with tools/call. The definitions slot straight into the tool list you already send to the model, so the agent loop from Section 1 does not change.
The idea in pseudocode
Real SDK calls differ by language and version, so this sketch shows the flow rather than exact method names.
session = connect(server_command) # 1. connect
tools = session.list_tools() # 2. discover
model_tools = [to_model_schema(t) for t in tools]
# inside the agent loop, when the model requests a tool:
result = session.call_tool(name, arguments) # 3. forward the callNamespace tool names
Two servers may both expose a tool called search. Prefix names with the server (for example issues_search) when merging tool lists so the model and your router never confuse them.
Quick check: Which MCP method returns the available tool definitions?
- tools/call
- tools/list
- prompts/run
- server/delete
Answer
tools/list — `tools/list` discovers tools; `tools/call` executes one.