Custom MCP Doesn't Work When Created via VAPI API
# support
r
I’m running into a problem when using a custom MCP server with a VAPI assistant created via the API. My MCP defines three tools: 1.
knowledge_base
2.
get_available_appointment_slots
3.
schedule_appointment
However, when I ask the assistant a question that should trigger
get_available_appointment_slots
, it instead calls the generic function name
mcpTools
. Here’s what I’m seeing in the
end-of-call-report
webhook data:
Copy code
json
"toolCalls": [
  {
    "id": "call_EdJTABIfAJ3Td03qGiEUioHt",
    "type": "function",
    "function": {
      "name": "mcpTools",
      "arguments": "{}"
    }
  }
]
Even though my MCP server correctly registers the tools using
server.registerTool('get_available_appointment_slots', ...)
, VAPI only sends calls to the MCP under the generic function name (
mcpTools
). Here’s the key part of my assistant’s configuration:
Copy code
json
"model": {
  "model": "gpt-4o",
  "tools": [
    {
      "type": "mcp",
      "server": {
        "url": mcpServerUrl,
        "headers": {
          "x-team-id": team_id,
          "x-mcp-tools": enabledTools,
          "x-assistant-id": assistant_id
        },
        "timeoutSeconds": 20
      },
      "function": { "name": "mcpTools" },
      "metadata": { "protocol": "shttp" }
    }
  ]
}
This problem only happens when attaching my MCP via the API. If I create the same MCP through the VAPI dashboard UI, everything works as expected — the assistant correctly calls
get_available_appointment_slots
. So my question is: How do I configure my assistant so that it calls the tool names defined in my MCP server (e.g.,
get_available_appointment_slots
) instead of the wrapper function name (
mcpTools
)?
It's as if the Vapi assistant doesn't list the available tools via the MCP server when invoked from Vapi's dashboard or from an inbound call.
v
Hey, I’ve seen this happen when the assistant doesn’t fetch the full MCP tool list dynamically through the API. I can help you fix it so it correctly calls your actual tools like get_available_appointment_slots instead of mcpTools. It usually comes down to how x-mcp-tools is passed in the headers. Are you sending it as a JSON array or plain string? That part often breaks tool mapping. @RyGuy
r
Hi @Vercel thanks for the response. The custom header, x-mcp-tools, that I set with the
enabledTools
variable is a JSON array. See below:
const enabledTools = JSON.stringify(["booking"])
That allows me to conditionally return both
get_available_appointment_slots
and
book_appointment
tools based on the user's privileges using the assistant. My custom headers are working just fine, but I think you're correct that my MCP server isn't listing the tools when created via the API. However, it works just fine if I create a global MCP server and manually add it to my assistant.
v
Yeah, you’re spot on — the issue comes from the API-created assistant not syncing your MCP tools automatically like it does through the dashboard. I can help you set it up so it dynamically loads and maps each tool correctly. Let’s chat privately, and I’ll walk you through how to fix it step by step. @RyGuy
c
Hi RyGuy, If you're looking to connect your AI assistant or application to Vapi's APIs using the Model Context Protocol (MCP), here's a quick overview of how to set it up: 1. **MCP Server Configuration**: - You can set up the connection to the Vapi-hosted MCP server with either the streamable-HTTP or Server-Sent Events (SSE) protocol. The recommended endpoint is
https://mcp.vapi.ai/mcp
for streamable HTTP. 2. **Authorization**: - Use your Vapi API key as a bearer token for authentication. Example for Claude Desktop would look like:
Copy code
json
   {
     "mcpServers": {
       "vapi-mcp": {
         "command": "npx",
         "args": [
           "mcp-remote", 
           "https://mcp.vapi.ai/mcp",
           "--header",
           "Authorization: Bearer ${VAPI_TOKEN}"
         ],
         "env": {
           "VAPI_TOKEN": "YOUR_VAPI_API_KEY"
         }
       }
     }
   }
3. **Creating and Using Tools**: - Vapi MCP Server provides tools like
list_assistants
,
create_call
, etc., which can be integrated and used to manage assistants and calls via your assistant or client. For a complete setup tutorial and examples, check out [this guide on Vapi's MCP Server](https://docs.vapi.ai/sdk/mcp-server). If you follow these steps and need further customization or run into issues, make sure your server URL and API key configurations are correct. Additionally, you can explore detailed setup examples in different programming languages from the [MCP integration documentation](https://docs.vapi.ai/cli/mcp).
m
Hi @RyGuy were you able to fix your issue? I am having the exact same issue and am stuck on what to do next
@Vercel
r
I ended up using tool functions instead
c
It was working for us really well, but then all of a sudden it's stopped recognizing the available tools in the MCP server and sending function calls to 'mcpTools' as a function call instead. Adding tool functions defeats the purpose and flexbility of using MCP servers!