Assistant Using mcpTools Instead of Custom MCP Too...
# support
r
I created an assistant via the API with a custom MCP server. My MCP has 3 tools: 1.
knowledge_base
2.
get_available_appointment_slots
3.
schedule_appointment
When I ask for availability (hoping for it to use
get_available_appointment_slots
, it’s calling the function name
mcpTools
instead of
get_available_appointment_slots
despite instructions in the system prompt to use
get_available_appointment_slots
. After reviewing the
end-of-call-report
webhook data, I can see it’s using the wrong function name in the
toolCalls
. See below:

Copy code
{"toolCalls": [
      {
        "id": "call_EdJTABIfAJ3Td03qGiEUioHt",
        "type": "function",
        "function": {
          "name": "mcpTools",
          "arguments": "{}"
        }
      },
      {
        "id": "call_1bsemJNPsJuWCcNeMHHWOtqv",
        "type": "function",
        "function": {
          "name": "mcpTools",
          "arguments": "{}"
        }
      }
    ],
    "role": "tool_calls",
    "message": "",
    "time": 1761844411824,
    "secondsFromStart": 26.659
},
Here is the assistant’s configuration:

Copy code
"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"
        }
      }
],
Am I doing something wrong? How do I make sure my assistant is calling the tools listed in my MCP server rather than the function name I gave my MCP server? callId =
019a361b-d3e9-7882-924a-bec9b3eb7544
orgId =
ae6fdc9a-4e2a-4f61-b4f6-e4da9aa7b825
v
Hey! I can help you with that — the issue happens because your assistant only sees the MCP server as one function (mcpTools) instead of the actual tools like get_available_appointment_slots. This usually means the MCP tool definitions aren’t being properly exposed or passed in the x-mcp-tools header. It’s worth checking how your MCP registers and returns its tool list in the handshake or /tools response. Could you share that part of your MCP setup? @RyGuy
r
Hi @Vignxt Flow, thanks for the quick reply. Here's what my server looks like during initialization:
Copy code
const {
    StreamableHTTPServerTransport,
} = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
const { initializeSalesAgentMcpServer } = require("../mcp/mcpServer.salesAgent");

/**
 * Health check for Sales Agent MCP server
 */
const getMcpHealth = (req, res) => {
    res.json({
        name: "Sales Agent MCP Server",
        version: "1.0.0",
        status: "running",
    });
};

/**
 * Handle MCP requests for Sales Agent (header-based behavior)
 */
const handleMcpRequest = async (req, res) => {
    try {
        // Forward relevant headers
        const requestHeaders = {
            authorization: req.headers.authorization,
            "mcp-session-id": req.headers["mcp-session-id"],
            "x-team-id": req.headers["x-team-id"],
            "x-assistant-id": req.headers["x-assistant-id"],
            "x-mcp-tools": req.headers["x-mcp-tools"],
        };

        const mcpServer = initializeSalesAgentMcpServer(requestHeaders);

        const transport = new StreamableHTTPServerTransport({
            sessionIdGenerator: undefined,
            enableJsonResponse: true,
        });

        res.on("close", () => {
            transport.close();
        });

        await mcpServer.connect(transport);
        await transport.handleRequest(req, res, req.body);
    } catch (error) {
        console.error("Error handling Sales Agent MCP request:", error);
        if (!res.headersSent) {
            res.status(500).json({
                jsonrpc: "2.0",
                error: {
                    code: -32603,
                    message: "Internal server error",
                },
                id: null,
            });
        }
    }
};

module.exports = {
    getMcpHealth,
    handleMcpRequest,
};
v
Hey, thanks for sharing that! I can help you sort this out, it looks like your server setup is solid, but the issue’s likely with how the tools are being registered or returned in your initializeSalesAgentMcpServer function. That’s why the assistant only sees mcpTools instead of your actual tool names. We can go through the registration part together and get it fixed quickly. Let’s chat more privately and maybe schedule a quick call to walk through it step by step. @RyGuy
r
@Vignxt Flow here's simplified code in the
initializeSalesAgentMcpServer
function
Copy code
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
const { z } = require("zod");

const initializeSalesAgentMcpServer = () => {
    const server = new McpServer({
        name: "Sales Agent MCP Server",
        version: "1.0.0",
    });

    // Conditionally register booking-related tools
    server.tool(
        "get_available_appointment_slots",
        "Fetch available appointment time slots between two dates.",
        {
            start: z
                .string()
                .describe(
                    "Start date (YYYY-MM-DD) to check for available appointment slots, inclusive."
                ),
            end: z
                .string()
                .describe(
                    "End date (YYYY-MM-DD) to check for available appointment slots, inclusive."
                ),
        },
        async ({ start, end }) => {
            console.log(
                `[MCP] get_available_appointment_slots: Checking availability from ${start} to ${end}`
            );

            try {
                // ...code

                return {
                    content: [
                        {
                            type: "text",
                            text: resultText,
                        },
                    ],
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Error checking availability: ${error.message}`,
                        },
                    ],
                };
            }
        }
    );

    return server;
};

module.exports = { initializeSalesAgentMcpServer };
m
Hi @Vignxt Flow , were you able to resolve this issue? I am getting the exact same issue for our agents
c
We are seeing the same issue on our end. MCP tools were working well a few weeks ago, but not its just calling as function name 'mcpTools'
2 Views