Learn how to add and configure MCP tools 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.
import { subAgent, 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 = subAgent({ 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 sub agent level using mcpTool.with. This allows different agents to use different subsets of tools from the same MCP server.
import { agent, mcpTool } from "@inkeep/agents-sdk";// Define the MCP server with all available toolsconst customerSupportTool = mcpTool({ id: "customer-support-tool", name: "Customer Support Tool", description: "Customer Support Tool", serverUrl: "https://customer-support.example.com/mcp",});// Agent that only uses specific tools from the serverconst customerSupportAgent = subAgent({ id: "customer-support-agent", name: "Customer Support Agent", description: "Responsible for customer support", prompt: "You are a helpful assistant", canUse: () => [customerSupportTool.with({ selectedTools: ["customer-support-tool"], headers: { "X-Custom-Header": "custom-value" } })],});
You can also configure MCP tools to switch based on your environment. This is useful when you want to use different MCP tool configurations for development vs production.
Creating environment-aware MCP tools is a two step process: