Anthropic’s Messages API supports remote MCP servers through their MCP connector feature. This allows you to give Claude models direct access to your tools and infrastructure by connecting to Gram-hosted MCP servers.
This guide will show you how to connect Anthropic’s API to a Gram-hosted MCP server using an example Push Advisor API . You’ll learn how to create an MCP server from an OpenAPI document, set up the connection, configure authentication, and use natural language to query the example API.
Here’s what each parameter in the mcp_servers array does:
type: "url" - Specifies this is a URL-based MCP server.
name - A unique identifier for your MCP server.
url - Your Gram-hosted MCP server URL.
authorization_token - Authentication token (optional for public servers).
tool_configuration - Tool filtering and permissions (optional).
Tool filtering and permissions
Using the tool_configuration parameter, you can control which tools are available for use in your MCP server while making an API call.
Filtering specific tools
If your Gram MCP server has multiple tools but you only want to expose certain ones in this particular API call, use the allowed_tools parameter:
import osfrom anthropic import Anthropicclient = Anthropic()response = client.beta.messages.create( model="claude-sonnet-4-20250514", max_tokens=1000, messages=[ { "role": "user", "content": "What is the vibe today?" } ], mcp_servers=[ { "type": "url", "url": "https://app.getgram.ai/mcp/canipushtoprod", "name": "gram-pushadvisor", "tool_configuration": { "enabled": True, "allowed_tools": [ "can_i_push_to_prod", # "vibe_check", # Excluded from the allowed tools ] } } ], betas=["mcp-client-2025-04-04"])for content in response.content: if content.type == "text": print(content.text)# Generic claude response, extra chipper and definitely not from our test server.
Note how the vibe_check tool is excluded from the allowed_tools list. This means it won’t be available for use in this API call, even if it’s defined in your curated toolset and MCP server.
Disabling tools
You can also disable all tools from a server while keeping the server connection active:
OpenAI: No special headers required for MCP support
Response format
Anthropic: Returns mcp_tool_use and mcp_tool_result blocks
OpenAI: Returns mcp_call and mcp_list_tools items
Testing your integration
If you encounter issues during integration, follow these steps to troubleshoot:
Validate MCP server connectivity
Before integrating into your application, test your Gram MCP server in the Gram Playground to ensure tools work correctly.
Use the MCP Inspector
Anthropic provides an MCP Inspector command line tool that helps you test and debug MCP servers before integrating them with Anthropic’s API. You can use it to validate your Gram MCP server’s connectivity and functionality.
To test your Gram MCP server with the Inspector:
# For public serversnpx -y @modelcontextprotocol/inspector
In the Transport Type field, select Streamable HTTP.
Enter your server URL in the URL field, for example:
https://app.getgram.ai/mcp/canipushtoprod
Click Connect to establish a connection to your MCP server.
Use the Inspector to verify that your MCP server responds correctly before integrating it with your Anthropic API calls.
What’s next
You now have Anthropic’s Claude models connected to your Gram-hosted MCP server, giving them access to your custom APIs and tools.
Ready to build your own MCP server? Try Gram today and see how easy it is to turn any API into agent-ready tools that work with both Anthropic and OpenAI models.