Skip to main content

Agent Integration

This guide helps AI agents use the MCP Gateway effectively. The gateway provides unified access to multiple MCP servers through a single endpoint.

Quick Start

1. list_servers()              # What servers are available?
2. list_tools(server="x") # What can this server do?
3. call(server="x", tool="y", args={...}, cwd="...") # Do it

Need help? Use docs(search="your question") at any time.

Gateway Tools Reference

ToolPurposeExample
list_servers()List available serverslist_servers(cwd="/project")
list_all_servers()List ALL configured serverslist_all_servers()
list_tools(server)List server's toolslist_tools(server="github")
describe_tool(server, tool)Get tool schemadescribe_tool(server="github", tool="create_issue")
call(server, tool, args, cwd)Execute a toolcall(server="fs", tool="read_file", args={...}, cwd="...")
list_catalog()Browse installable serverslist_catalog()
install_server(server, scope)Install from cataloginstall_server(server="sqlite", scope="global")
manage_config(action, ...)Modify gateway configmanage_config(action="get")
docs(search)Search documentationdocs(search="environment variables")

Common Use Cases

"I need to use a tool but don't know what's available"

# Step 1: See available servers
list_servers()

# Step 2: Pick a server, see its tools
list_tools(server="github")

# Step 3: Get details on a specific tool
describe_tool(server="github", tool="create_issue")

# Step 4: Call the tool with project context
call(
server="github",
tool="create_issue",
args={"title": "Bug fix", "body": "..."},
cwd="/path/to/project"
)

"I need to install a new MCP server"

# Browse the catalog
list_catalog()

# Install globally (available to all projects)
install_server(server="playwright", scope="global")

# Or install for a specific project
install_server(server="playwright", cwd="/path/to/project")
Important

Global installs require scope="global" - this prevents accidental global modifications.

"I'm getting authentication/permission errors"

# Check if you're passing project context
call(server="github", tool="...", cwd="/path/to/project") # cwd is required!

# Check what env vars the server needs
docs(search="github environment variables")

# Make sure .env file exists at project root with required vars

"I need to search documentation"

# Search for any topic
docs(search="how to configure postgres")

# Browse available topics
docs()

# Get help with errors
docs(search="MISSING_ENV_VARS error")

Project Context

Most operations need to know which project you're working in. This determines:

  • Which .env file to load
  • Which servers are available
  • Which credentials to use

How to Pass Context

Option 1: In every request (recommended)

call(server="x", tool="y", args={...}, cwd="/path/to/project")

Option 2: Via HTTP headers (set once per session)

X-MCP-Cwd: /path/to/project
X-MCP-Project: my-project-name

Option 3: Via project token (remote access)

When using a project-specific bearer token, the project is automatically identified from the token. No need to pass cwd or headers.

Error Handling

The gateway provides helpful errors. Always check hint and suggestion fields.

Error CodeMeaningWhat to Do
TOOL_NOT_FOUNDTool doesn't exist on serverRun list_tools(server="...")
SERVER_UNAVAILABLEServer crashed or won't startCheck logs, try install_server()
MISSING_ENV_VARSServer needs API keysAdd to .env file in project root
ACCESS_DENIEDWrong project contextPass correct cwd parameter
SCOPE_REQUIREDGlobal change without scopeAdd scope="global" to request

Example Error Response

{
"error": "Global install requires explicit scope",
"hint": "To install globally, use: install_server(server=\"sqlite\", scope=\"global\")",
"suggestion": "install_server(server=\"sqlite\", scope=\"global\")"
}

Self-Service Help

The docs() tool searches the gateway's knowledge base. Use it when stuck:

# General questions
docs(search="how do I configure a new server")

# Error help
docs(search="what does ACCESS_DENIED mean")

# Feature questions
docs(search="http headers project context")

# Server-specific help
docs(search="postgres setup")

Configuration Changes

All config modifications require explicit scope="global":

# Install a server globally
install_server(server="sqlite", scope="global")

# Add a new server to config
manage_config(
action="add_server",
name="my-custom-server",
scope="global",
data={"url": "http://localhost:9000/mcp"}
)

# Add a new project
manage_config(
action="add_project",
name="my-app",
scope="global",
data={"path": "/home/user/my-app", "capabilities": ["github", "postgres"]}
)

# Read config (no scope needed)
manage_config(action="get")

Best Practices

  1. Explore before guessing - Use list_tools and describe_tool instead of guessing tool names
  2. Always pass context - Include cwd in tool calls for proper credential resolution
  3. Read error hints - The gateway tells you exactly how to fix problems
  4. Use docs() - Self-service help is built into the gateway
  5. Be explicit with scope - Config changes need scope="global" to prevent accidents