POST
/api/v1/mcp/invokeInvoke an MCP server tool
Gateway endpoint for invoking a tool on a registered Model Context Protocol (MCP) server. Validates JWT (when server.authType='jwt'), enforces per-tool RBAC against mcp_tool_permissions.allowed_roles, applies sliding-window rate-limit per (server, tool), and forwards to the upstream server. Every invocation (allow/deny/error) is recorded to mcp_tool_invocations for audit.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/api-keys.
Request body required
Example
{
"serverId": "<mcp_servers.id>",
"toolName": "<Tool name registered on the server>",
"arguments": {},
"jwt": "<Bearer JWT when server.authType='jwt'>"
}Schema
{
"application/json": {
"schema": {
"type": "object",
"required": [
"serverId",
"toolName"
],
"properties": {
"serverId": {
"type": "string",
"description": "mcp_servers.id"
},
"toolName": {
"type": "string",
"description": "Tool name registered on the server"
},
"arguments": {
"type": "object",
"description": "Tool-specific arguments forwarded to upstream",
"additionalProperties": true
},
"jwt": {
"type": "string",
"description": "Bearer JWT when server.authType='jwt'"
}
}
}
}
}Response
200 example
{
"success": true
}All status codes
200Tool invoked successfully.
400(no description)
401(no description)
403Forbidden — caller's role not in tool's allowed_roles, or JWT validation failed.
404Server or tool permission row not found.
429(no description)
501Transport not implemented (only HTTP transport forwards today; stdio/SSE/WS still audit-log but return 501).
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/mcp/invoke \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "serverId": "<mcp_servers.id>", "toolName": "<Tool name registered on the server>", "arguments": {}, "jwt": "<Bearer JWT when server.authType='jwt'>" }'TypeScript
import { EvalGuard } from "@evalguard/sdk";
const client = new EvalGuard({ apiKey: process.env.EVALGUARD_API_KEY });
const response = await client.request({
method: "POST",
path: "/api/v1/mcp/invoke",
body: {
"serverId": "<mcp_servers.id>",
"toolName": "<Tool name registered on the server>",
"arguments": {},
"jwt": "<Bearer JWT when server.authType='jwt'>"
},
});
console.log(response);Python
from evalguard import EvalGuard
import os
client = EvalGuard(api_key=os.environ["EVALGUARD_API_KEY"])
response = client.request(
method="POST",
path="/api/v1/mcp/invoke",
body={
"serverId": "<mcp_servers.id>",
"toolName": "<Tool name registered on the server>",
"arguments": {},
"jwt": "<Bearer JWT when server.authType='jwt'>"
},
)
print(response)Go
package main
import (
"context"
"fmt"
"os"
"github.com/evalguard/evalguard-go"
)
func main() {
client := evalguard.NewClient(os.Getenv("EVALGUARD_API_KEY"))
resp, err := client.Request(context.Background(), "POST", "/api/v1/mcp/invoke", map[string]any{"serverId": "<mcp_servers.id>", "toolName": "<Tool name registered on the server>", "arguments": map[string]any{}, "jwt": "<Bearer JWT when server.authType='jwt'>"})
if err != nil { panic(err) }
fmt.Println(resp)
}Errors
400401403404429501