Ask HN: How does MCP tool calling work?

1 revskill 1 8/1/2025, 1:00:53 PM
I found it's a bit confusing on how exactly the tool calling work, where does it work ?

Let's say we have a server, with an ai agent configured with tools.

We also have client, which call openai api , and it's also provided with mcp servers.

So when we prompt, how does the whole mcp servers, tool calling resolution and tool execution actually work ? Where does it execute ?

Comments (1)

mrpound · 54m ago
In general, an agent will make an API call to an MCP server to get a list of available tools or to execute a specific tool. For example, when you send a request to OpenAI's Responses API and include a tool call to one of their tools (e.g. web search), the actual execution always occurs on the remote server.

You can also make remote MCP calls over the OpenAI Responses API, which will basically proxy the request to the remote MCP server URL you pass in the request. The execution is always happening on the MCP server hosting the tool.

You can run your own MCP server and expose your own custom tools, rather than hitting someone else's remote service. You can also use function calling w/ OpenAI to let a model decide which custom code to execute without using MCP. With my agents I use a bit of both depending on use case. Sometimes it's easier to use a prompt that outputs a JSON object containing some arguments and a function name defined in your agent code, you call your function and then pass the result back to the model.

At the end of the day MCP is just a protocol, so it's up to you how much you want to implement yourself and what you want to offload to remote providers (just be mindful of whose tools you're calling and what context is being passed in your tool calls).