{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/philschmid-de/2026-04-27-how-to-correctly-use-mcp-servers-with-your-ai-agents/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "MCP servers are not dead. But blindly enabling them bloats your context, which leads to higher cost and worse performance. Unlike Agent Skills, MCP servers don't come with progressive disclosure out of the box. It is your responsibility to select the tools needed for the task at hand. Here are two proven patterns on how to correctly use MCP servers and avoid the bloat.\n\n## 1\\. Explicit MCP Servers: Inline Tool Injection\n\nMCP servers stay **opt-in**. Servers are referenced in your prompt with an `@mention`, and the agent resolves, fetches, and injects the tools before the model request.\n\n![Explicit MCP Servers: Inline Tool Injection](https://www.philschmid.de/static/blog/use-mcp-servers/mcp-inline.png)\n\nWriting `@github` or `@slack` in a prompt triggers the agent to:\n\n1. **Resolve** the `@mention` to a registered MCP server URL\n2. **Fetch** tool schemas from the server\n3. **Inject** them into the `tools[]` array of the API request\n4. **Forward** everything to the model, which decides what to call\n\nNothing loads unless requested. The tool surface stays small.\n\nTypeScript\n\n```typescript\n// Pseudo-code\nasync function handlePrompt(prompt: string) {\n  // Detect @mentions in the prompt\n  const mentions = parseMentions(prompt); // [\"@github\", \"@slack\"]\n  \n  // Resolve each mention to an MCP server\n  const servers = mentions.map(m => mcpServers.resolve(m));\n  \n  // Fetch tool schemas from each server\n  const mcpTools = await Promise.all(\n    servers.map(s => s.listTools())\n  );\n  \n  // Inject into the API request alongside native tools\n  const response = await llmCall({\n    prompt,\n    tools: [...nativeTools, ...mcpTools],\n  });\n  \n  // handle response, call tools, etc ... \n}\n```\n\n**When to use this:** MCP usage is occasional and user-driven. Someone asks a question that needs Slack or GitHub data, they `@mention` the server, and it gets pulled in for that request only. Keeps costs low and avoids tool noise on tasks that don't need external integrations.\n\n## 2\\. Subagent MCP Servers\n\nMCP servers are declared in subagents definition and automatically available at runtime alongside native tools like `read_file` or `run_command`.\n\n![Subagent MCP Servers](https://www.philschmid.de/static/blog/use-mcp-servers/mcp-subagent.png)\n\nEach subagent has its own configuration that declares its model, tools,... and optional MCP servers. You can scope MCP servers to specific tools using `allowed_tools`.\n\nYAML\n\n```yaml\n# Pseudo-code: code_reviewer.md\n---\nname: code-reviewer\nmodel: gemini-3-flash\nmcp_servers:\n  - url: https://github-mcp.example\n    allowed_tools:\n      - list_pulls\n      - list_reviews\n      - get_diff\n---\nYou are a code reviewer. Review open PRs...\n```\n\nThe main agent registers subagents. When invoked, each subagent connects to its declared MCP servers and merges those tools with native ones.\n\nTypeScript\n\n```typescript\n// Pseudo-code\n \n// Register subagents as tools for the orchestrator\nconst codeReviewer = createSubagent(\"./agents/code_reviewer.md\");\nconst slackMonitor = createSubagent(\"./agents/slack_monitor.md\");\n \nasync function handlePrompt(prompt: string) {\n \n  // pre-processing ...\n \n  const response = await llmCall({\n    prompt,\n    tools: [...nativeTools, codeReviewer, slackMonitor],\n  });\n \n  // handle response, call tools, etc ...\n}\n```\n\n`allowed_tools` gives you least-privilege scoping without forking the MCP server.\n\n**When to use this:** The use case dictates the tools. A code review agent always needs GitHub, a support agent always needs Zendesk. The MCP servers are part of what the agent *is*, not something a user opts into per request. `allowed_tools` keeps each agent scoped to what it actually needs.\n",
  "authors": [],
  "captured_at": "2026-09-27T19:29:15.293681927+00:00",
  "category": "programming",
  "content_html": "<p>MCP servers are not dead. But blindly enabling them bloats your context, which leads to higher cost and worse performance. Unlike Agent Skills, MCP servers don't come with progressive disclosure out of the box. It is your responsibility to select the tools needed for the task at hand. Here are two proven patterns on how to correctly use MCP servers and avoid the bloat.</p>\n<h2>1. Explicit MCP Servers: Inline Tool Injection</h2>\n<p>MCP servers stay <strong>opt-in</strong>. Servers are referenced in your prompt with an <code>@mention</code>, and the agent resolves, fetches, and injects the tools before the model request.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://www.philschmid.de/static/blog/use-mcp-servers/mcp-inline.png\" alt=\"Explicit MCP Servers: Inline Tool Injection\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>Writing <code>@github</code> or <code>@slack</code> in a prompt triggers the agent to:</p>\n<ol>\n<li><strong>Resolve</strong> the <code>@mention</code> to a registered MCP server URL</li>\n<li><strong>Fetch</strong> tool schemas from the server</li>\n<li><strong>Inject</strong> them into the <code>tools[]</code> array of the API request</li>\n<li><strong>Forward</strong> everything to the model, which decides what to call</li>\n</ol>\n<p>Nothing loads unless requested. The tool surface stays small.</p>\n<p>TypeScript</p>\n<pre><code class=\"language-typescript\"><span class=\"code-snippet\" data-language=\"TypeScript\"><span class=\"syntax-source syntax-js\"><span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Pseudo-code\n</span><span class=\"syntax-meta syntax-function syntax-declaration syntax-js\"><span class=\"syntax-storage syntax-type syntax-js\">async</span> <span class=\"syntax-storage syntax-type syntax-function syntax-js\">function</span> <span class=\"syntax-entity syntax-name syntax-function syntax-js\">handlePrompt</span><span class=\"syntax-punctuation syntax-section syntax-group syntax-begin syntax-js\">(</span><span class=\"syntax-variable syntax-parameter syntax-function syntax-js\">prompt</span>: <span class=\"syntax-variable syntax-parameter syntax-function syntax-js\">string</span><span class=\"syntax-punctuation syntax-section syntax-group syntax-end syntax-js\">)</span><span class=\"syntax-meta syntax-function syntax-declaration syntax-js\"> </span></span><span class=\"syntax-meta syntax-block syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Detect @mentions in the prompt\n</span>  <span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">mentions</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-meta syntax-function-call syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">parseMentions</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">prompt</span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span> <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> [&quot;@github&quot;, &quot;@slack&quot;]\n</span>  \n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Resolve each mention to an MCP server\n</span>  <span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">servers</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-variable syntax-other syntax-object syntax-js\">mentions</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">map</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-meta syntax-function syntax-declaration syntax-js\"><span class=\"syntax-variable syntax-parameter syntax-function syntax-js\">m</span> <span class=\"syntax-storage syntax-type syntax-function syntax-arrow syntax-js\">=&gt;</span></span> <span class=\"syntax-meta syntax-block syntax-js\"><span class=\"syntax-variable syntax-other syntax-object syntax-js\">mcpServers</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">resolve</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">m</span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n  \n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Fetch tool schemas from each server\n</span>  <span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">mcpTools</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">await</span> <span class=\"syntax-support syntax-class syntax-builtin syntax-js\">Promise</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">all</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span>\n    <span class=\"syntax-variable syntax-other syntax-object syntax-js\">servers</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">map</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-meta syntax-function syntax-declaration syntax-js\"><span class=\"syntax-variable syntax-parameter syntax-function syntax-js\">s</span> <span class=\"syntax-storage syntax-type syntax-function syntax-arrow syntax-js\">=&gt;</span></span> <span class=\"syntax-meta syntax-block syntax-js\"><span class=\"syntax-variable syntax-other syntax-object syntax-js\">s</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">listTools</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span>\n  </span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n  \n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Inject into the API request alongside native tools\n</span>  <span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">response</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">await</span> <span class=\"syntax-meta syntax-function-call syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">llmCall</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-meta syntax-object-literal syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n    <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">prompt</span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n    <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">tools</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-meta syntax-sequence syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">[</span><span class=\"syntax-keyword syntax-operator syntax-spread syntax-js\">...</span><span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">nativeTools</span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span> <span class=\"syntax-keyword syntax-operator syntax-spread syntax-js\">...</span><span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">mcpTools</span><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">]</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n  <span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n  \n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> handle response, call tools, etc ... \n</span><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span>\n</span></span></code></pre>\n<p><strong>When to use this:</strong> MCP usage is occasional and user-driven. Someone asks a question that needs Slack or GitHub data, they <code>@mention</code> the server, and it gets pulled in for that request only. Keeps costs low and avoids tool noise on tasks that don't need external integrations.</p>\n<h2>2. Subagent MCP Servers</h2>\n<p>MCP servers are declared in subagents definition and automatically available at runtime alongside native tools like <code>read_file</code> or <code>run_command</code>.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://www.philschmid.de/static/blog/use-mcp-servers/mcp-subagent.png\" alt=\"Subagent MCP Servers\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>Each subagent has its own configuration that declares its model, tools,... and optional MCP servers. You can scope MCP servers to specific tools using <code>allowed_tools</code>.</p>\n<p>YAML</p>\n<pre><code class=\"language-yaml\"><span class=\"code-snippet\" data-language=\"YAML\"><span class=\"syntax-source syntax-yaml\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-yaml\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-line syntax-number-sign syntax-yaml\">#</span> Pseudo-code: code_reviewer.md\n</span><span class=\"syntax-entity syntax-other syntax-document syntax-begin syntax-yaml\">---</span>\n<span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">name</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">code-reviewer</span>\n<span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">model</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">gemini-3-flash</span>\n<span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">mcp_servers</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span>\n  <span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">url</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">https://github-mcp.example</span>\n    <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\"><span class=\"syntax-entity syntax-name syntax-tag syntax-yaml\">allowed_tools</span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-mapping syntax-yaml\">:</span>\n      <span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">list_pulls</span>\n      <span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">list_reviews</span>\n      <span class=\"syntax-punctuation syntax-definition syntax-block syntax-sequence syntax-item syntax-yaml\">-</span> <span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">get_diff</span>\n<span class=\"syntax-entity syntax-other syntax-document syntax-begin syntax-yaml\">---</span>\n<span class=\"syntax-string syntax-unquoted syntax-plain syntax-out syntax-yaml\">You are a code reviewer. Review open PRs...</span>\n</span></span></code></pre>\n<p>The main agent registers subagents. When invoked, each subagent connects to its declared MCP servers and merges those tools with native ones.</p>\n<p>TypeScript</p>\n<pre><code class=\"language-typescript\"><span class=\"code-snippet\" data-language=\"TypeScript\"><span class=\"syntax-source syntax-js\"><span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Pseudo-code\n</span> \n<span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> Register subagents as tools for the orchestrator\n</span><span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">codeReviewer</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-meta syntax-function-call syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">createSubagent</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>./agents/code_reviewer.md<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n<span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">slackMonitor</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-meta syntax-function-call syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">createSubagent</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>./agents/slack_monitor.md<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n \n<span class=\"syntax-meta syntax-function syntax-declaration syntax-js\"><span class=\"syntax-storage syntax-type syntax-js\">async</span> <span class=\"syntax-storage syntax-type syntax-function syntax-js\">function</span> <span class=\"syntax-entity syntax-name syntax-function syntax-js\">handlePrompt</span><span class=\"syntax-punctuation syntax-section syntax-group syntax-begin syntax-js\">(</span><span class=\"syntax-variable syntax-parameter syntax-function syntax-js\">prompt</span>: <span class=\"syntax-variable syntax-parameter syntax-function syntax-js\">string</span><span class=\"syntax-punctuation syntax-section syntax-group syntax-end syntax-js\">)</span><span class=\"syntax-meta syntax-function syntax-declaration syntax-js\"> </span></span><span class=\"syntax-meta syntax-block syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n \n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> pre-processing ...\n</span> \n  <span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">response</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">await</span> <span class=\"syntax-meta syntax-function-call syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">llmCall</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-meta syntax-object-literal syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n    <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">prompt</span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n    <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">tools</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-meta syntax-sequence syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">[</span><span class=\"syntax-keyword syntax-operator syntax-spread syntax-js\">...</span><span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">nativeTools</span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">codeReviewer</span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">slackMonitor</span><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">]</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n  <span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n \n  <span class=\"syntax-comment syntax-line syntax-double-slash syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-js\">//</span> handle response, call tools, etc ...\n</span><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span>\n</span></span></code></pre>\n<p><code>allowed_tools</code> gives you least-privilege scoping without forking the MCP server.</p>\n<p><strong>When to use this:</strong> The use case dictates the tools. A code review agent always needs GitHub, a support agent always needs Zendesk. The MCP servers are part of what the agent <em>is</em>, not something a user opts into per request. <code>allowed_tools</code> keeps each agent scoped to what it actually needs.</p>\n",
  "content_markdown": "MCP servers are not dead. But blindly enabling them bloats your context, which leads to higher cost and worse performance. Unlike Agent Skills, MCP servers don't come with progressive disclosure out of the box. It is your responsibility to select the tools needed for the task at hand. Here are two proven patterns on how to correctly use MCP servers and avoid the bloat.\n\n## 1\\. Explicit MCP Servers: Inline Tool Injection\n\nMCP servers stay **opt-in**. Servers are referenced in your prompt with an `@mention`, and the agent resolves, fetches, and injects the tools before the model request.\n\n![Explicit MCP Servers: Inline Tool Injection](https://www.philschmid.de/static/blog/use-mcp-servers/mcp-inline.png)\n\nWriting `@github` or `@slack` in a prompt triggers the agent to:\n\n1. **Resolve** the `@mention` to a registered MCP server URL\n2. **Fetch** tool schemas from the server\n3. **Inject** them into the `tools[]` array of the API request\n4. **Forward** everything to the model, which decides what to call\n\nNothing loads unless requested. The tool surface stays small.\n\nTypeScript\n\n```typescript\n// Pseudo-code\nasync function handlePrompt(prompt: string) {\n  // Detect @mentions in the prompt\n  const mentions = parseMentions(prompt); // [\"@github\", \"@slack\"]\n  \n  // Resolve each mention to an MCP server\n  const servers = mentions.map(m => mcpServers.resolve(m));\n  \n  // Fetch tool schemas from each server\n  const mcpTools = await Promise.all(\n    servers.map(s => s.listTools())\n  );\n  \n  // Inject into the API request alongside native tools\n  const response = await llmCall({\n    prompt,\n    tools: [...nativeTools, ...mcpTools],\n  });\n  \n  // handle response, call tools, etc ... \n}\n```\n\n**When to use this:** MCP usage is occasional and user-driven. Someone asks a question that needs Slack or GitHub data, they `@mention` the server, and it gets pulled in for that request only. Keeps costs low and avoids tool noise on tasks that don't need external integrations.\n\n## 2\\. Subagent MCP Servers\n\nMCP servers are declared in subagents definition and automatically available at runtime alongside native tools like `read_file` or `run_command`.\n\n![Subagent MCP Servers](https://www.philschmid.de/static/blog/use-mcp-servers/mcp-subagent.png)\n\nEach subagent has its own configuration that declares its model, tools,... and optional MCP servers. You can scope MCP servers to specific tools using `allowed_tools`.\n\nYAML\n\n```yaml\n# Pseudo-code: code_reviewer.md\n---\nname: code-reviewer\nmodel: gemini-3-flash\nmcp_servers:\n  - url: https://github-mcp.example\n    allowed_tools:\n      - list_pulls\n      - list_reviews\n      - get_diff\n---\nYou are a code reviewer. Review open PRs...\n```\n\nThe main agent registers subagents. When invoked, each subagent connects to its declared MCP servers and merges those tools with native ones.\n\nTypeScript\n\n```typescript\n// Pseudo-code\n \n// Register subagents as tools for the orchestrator\nconst codeReviewer = createSubagent(\"./agents/code_reviewer.md\");\nconst slackMonitor = createSubagent(\"./agents/slack_monitor.md\");\n \nasync function handlePrompt(prompt: string) {\n \n  // pre-processing ...\n \n  const response = await llmCall({\n    prompt,\n    tools: [...nativeTools, codeReviewer, slackMonitor],\n  });\n \n  // handle response, call tools, etc ...\n}\n```\n\n`allowed_tools` gives you least-privilege scoping without forking the MCP server.\n\n**When to use this:** The use case dictates the tools. A code review agent always needs GitHub, a support agent always needs Zendesk. The MCP servers are part of what the agent *is*, not something a user opts into per request. `allowed_tools` keeps each agent scoped to what it actually needs.\n",
  "dateCreated": "2026-09-27T19:29:15.293681927+00:00",
  "date_created": "2026-04-27T00:00:00+00:00",
  "date_modified": "2026-04-27T00:00:00+00:00",
  "date_published": "2026-04-27T00:00:00+00:00",
  "description": "MCP servers are not dead. Blindly enabling them bloats your context, which leads to higher cost and worse performance. Here are two proven patterns on how to correctly use MCP servers and avoid the bloat.",
  "external_url": "https://www.philschmid.de/use-mcp-servers",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/philschmid-de/2026/04/2026-04-27-how-to-correctly-use-mcp-servers-with-your-ai-agents.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/philschmid-de/2026/04/2026-04-27-how-to-correctly-use-mcp-servers-with-your-ai-agents.md"
  },
  "id": "urn:aggr:item:2f84c8178e94e34ee637744af47bcc28b1d73286",
  "isBasedOn": {
    "@id": "https://www.philschmid.de/use-mcp-servers"
  },
  "mainEntity": {
    "@id": "https://www.philschmid.de/use-mcp-servers",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/philschmid-de/2026-04-27-how-to-correctly-use-mcp-servers-with-your-ai-agents/#webpage"
    },
    "dateModified": "2026-04-27T00:00:00+00:00",
    "datePublished": "2026-04-27T00:00:00+00:00",
    "headline": "How to correctly use MCP servers with your AI Agents",
    "timeRequired": "PT3M",
    "url": "https://www.philschmid.de/use-mcp-servers",
    "wordCount": 468
  },
  "name": "Archived snapshot: How to correctly use MCP servers with your AI Agents",
  "preview": null,
  "reading_minutes": 3,
  "replicated_at": null,
  "source": "philschmid-de",
  "source_name": "philschmid.de - RSS feed",
  "summary": "MCP servers are not dead. Blindly enabling them bloats your context, which leads to higher cost and worse performance. Here are two proven patterns on how to correctly use MCP servers and avoid the bloat.",
  "tags": [],
  "temporalCoverage": "2026-09-27T19:29:15.293681927+00:00",
  "title": "How to correctly use MCP servers with your AI Agents",
  "url": "https://aggr.aymericbeaumet.com/items/philschmid-de/2026-04-27-how-to-correctly-use-mcp-servers-with-your-ai-agents/",
  "word_count": 468
}