Portkey MCP Gateway works with any MCP client. Connect your agents using a URL and API key.
Find your connection URL
Go to MCP in your workspace sidebar. Click on a server to see its connection details.
Each server has a URL:
https://mcp.portkey.ai/{server-slug}/mcp
Copy this URL to use in your agent configuration.
For self-hosted deployments, replace mcp.portkey.ai with your gateway URL.
Claude Desktop
Add to your Claude Desktop config file.
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"linear": {
"url": "https://mcp.portkey.ai/linear/mcp",
"headers": {
"Authorization": "Bearer YOUR_PORTKEY_API_KEY"
}
}
}
}
Restart Claude Desktop after saving. The tools appear in your conversation.
If the server uses OAuth, Claude prompts you to authenticate when you first use a tool.
Cursor
Open Cmd/Ctrl + Shift + P > Cursor Settings: Open MCP Settings.
{
"mcpServers": {
"linear": {
"url": "https://mcp.portkey.ai/linear/mcp",
"headers": {
"Authorization": "Bearer YOUR_PORTKEY_API_KEY"
}
}
}
}
The tools are available in Cursor’s agent mode.
VS Code
With GitHub Copilot and the MCP extension:
{
"mcp.servers": {
"linear": {
"url": "https://mcp.portkey.ai/linear/mcp",
"headers": {
"Authorization": "Bearer YOUR_PORTKEY_API_KEY"
}
}
}
}
Python
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
url = "https://mcp.portkey.ai/linear/mcp"
headers = {"Authorization": "Bearer YOUR_PORTKEY_API_KEY"}
async with streamablehttp_client(url, headers=headers) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
# List tools
tools = await session.list_tools()
for tool in tools.tools:
print(f"{tool.name}: {tool.description}")
# Call a tool
result = await session.call_tool(
"create_issue",
{"title": "Bug report", "priority": "high"}
)
print(result)
TypeScript
npm install @modelcontextprotocol/sdk
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const transport = new StreamableHTTPClientTransport(
new URL("https://mcp.portkey.ai/linear/mcp"),
{
requestInit: {
headers: { "Authorization": "Bearer YOUR_PORTKEY_API_KEY" }
}
}
);
const client = new Client({ name: "my-agent", version: "1.0.0" });
await client.connect(transport);
const tools = await client.listTools();
console.log(tools);
const result = await client.callTool({
name: "search_issues",
arguments: { query: "bug" }
});
console.log(result);
API keys
Create API keys in Settings > API Keys. Keys are scoped to teams, so the key determines which MCP servers your agent can access.
Handling OAuth
If an MCP server uses OAuth for per-user authentication, users need to complete OAuth consent before using tools.
The first time a user calls a tool, Portkey returns an error with an authorization URL. Redirect the user to complete OAuth. After consent, retry the request.
try:
result = await session.call_tool("get_repos", {})
except Exception as e:
if "authorization_url" in str(e):
# Redirect user to authorize
print(f"Please authorize: {authorization_url}")
After authorization, Portkey stores the user’s tokens and handles refresh automatically.
AI Gateway integration
If you use Portkey’s AI Gateway for LLM calls, MCP integrates automatically:
- Unified dashboard for LLM and MCP activity
- Traces span model calls and tool use
- Single API key for both services