Learn how to add and configure MCP servers for your agents
MCP tools connect to external servers that implement the MCP standard. This allows you to integrate with a wide ecosystem of existing tools and services.
For some tips on leveraging existing MCP server libraries or creating your own MCP server, see here.
Once you have an MCP server, now you can add it to your Agents.
import { agent, mcpTool } from "@inkeep/agents-sdk";const knowledgeBaseTool = mcpTool({ id: "knowledge-base-tool", name: "knowledge_base", description: "Search the company knowledge base for information", serverUrl: "https://kb.yourcompany.com/mcp",});const qaAgent = agent({ id: "qa-agent", name: "QA Agent", description: "Responsible for answering questions about the company knowledge base.", prompt: `You are a Question-Answer agent that can answer questions about the company knowledge base. You have access to the knowledge base tool to search for information.`, canUse: () => [knowledgeBaseTool],});
Note
Tip: When adding tools to an agent, you can also reference the tool in the agent's prompt to help the agent understand how to use the tool.
You can configure custom headers for your MCP server requests. Use credentials for sensitive information (API keys, tokens) and headers for non-sensitive metadata (user agent, version info, etc.).
import { mcpTool } from "@inkeep/agents-sdk";const customHeadersTool = mcpTool({ id: "enterprise-api", name: "enterprise_data", description: "Enterprise API with custom headers", serverUrl: "https://enterprise.example.com/mcp", headers: { "User-Agent": "Inkeep-Agent/1.0", "X-Client-Version": "2024.1", },});
While activeTools in mcpTool limits which tools are available from the server, you can further refine tool access at the agent level using agentMcp. This allows different agents to use different subsets of tools from the same MCP server.
import { agent, mcpTool, agentMcp } from "@inkeep/agents-sdk";// Define the MCP server with all available toolsconst echoTool = mcpTool({ id: "echo-tool", name: "Echo tool", serverUrl: "https://mcp-for-next-js-seven-iota.vercel.app/mcp",});// Agent that only uses specific tools from the serverconst weatherAssistant = agent({ id: "weather-assistant", name: "Weather assistant", description: "Responsible for routing between the geocoder agent and weather forecast agent", prompt: "You are a helpful assistant. When the user asks about the weather in a given location, first ask the geocoder agent for the coordinates, and then pass those coordinates to the weather forecast agent to get the weather forecast", canDelegateTo: () => [weatherForecaster, geocoderAgent], canUse: () => [agentMcp({ server: echoTool, selectedTools: ["echo2"] })],});