Skip to content

MCP integrations

MCP (Model Context Protocol) lets your agents use tools from external servers — GitHub, Jira, databases, custom services — without writing Python wrappers.

MCP vs custom @tool: - Use MCP when a ready-made server already exists for the integration (GitHub, Atlassian, Monte Carlo, etc.) or when the tool is maintained by a different team - Use a custom @tool when you need tight control over the implementation, custom retry logic, or the tool is specific to your project

In abt, MCP sources are declared as JSON files; tools are referenced as source__tool_name.

Source files

Place one or more .json files under mcps/ (or the directory from abt.yaml → paths.mcps). mcps is a directory, not a file. Every .json file in it is discovered automatically (non-recursive). If that path exists but is a file, abt compile exits 2 with:

ERROR: MCP sources path must be a directory, not a file: /path/to/my-project/mcps. Check paths.mcps in abt.yaml.

Treat mcps/ like code

A stdio source's command/args/env start a process, and env_var() in url/headers is resolved from the environment and sent to that URL. Both run whenever sources are connected (abt run, and abt compile with --live or flags: live_compile: true). Only compile or run a project whose mcps/ you trust.

Sources are registered during abt compile and at run time, not at Python import time.

abt compile parses every *.json file in mcps/, even without --live. A file that is not valid JSON, has keys other than the ones in JSON shape, or has a malformed env_var() call fails the compile (exit 1).

An env_var('NAME') with NAME unset and no default only warns, so abt doctor, abt list, abt docs generate and CI jobs without MCP credentials keep working:

⚠ MCP source 'github' needs MCP_GITHUB_TOKEN (not set); runs that use it and --live compile will fail.

--live compile and every run that loads the source's tools fail instead (E_ENV_VAR_MISSING). Set the variable or remove the source from mcps/. With MCP_GITHUB_TOKEN unset, abt compile --live ends with:

ERROR: MCP source validation failed:
- github: env_var: environment variable 'MCP_GITHUB_TOKEN' is not set and no default was given.

A run that loads the source's tools fails with ERROR: MCP source 'github': env_var: not set and no default was given: MCP_GITHUB_TOKEN., one line per unset source. Only --live (or flags: live_compile: true) goes on to start the servers and ask them for their tools. If a server can't be reached, --live fails the compile with ERROR: MCP tool validation failed: and exit 2. A tool spec that names an unknown source fails every compile the same way.

Tool spec syntax

In agents/**/*.md frontmatter (wherever tools are listed for MCP-backed tools):

tools:
  - github__search_code
  - montecarlo__getTable
  • github — the MCP source name (the discovered file’s stem, e.g. github.json → github).
  • search_code — the tool name exposed by that server.

All tools from a source (wildcard)

Use source__* to load every tool the server exposes. Useful for exploratory agents or when the upstream tool catalog changes often:

tools:
  - github__*

Trade-offs to weigh before reaching for the wildcard:

  • Token cost — more tools means a larger system prompt on every LLM call.
  • Coupling — the agent’s available actions become tied to whatever the upstream server ships, including new tools added in future server versions.
  • Auditability — for tightly scoped or production agents, prefer explicit source__tool_name lines so the surface area is visible at a glance.

Notes:

  • If both source__* and explicit source__tool_name specs appear for the same source, the wildcard wins and all tools are loaded.
  • Only a single bare * is supported; source__** or source__list_* are treated as literal tool names (not found → warning).
  • MCP tools reach the model under their bare server name, so an MCP tool can't share one with another of the agent's tools (e.g. two MCP servers both exposing search_code, a package's gh__search_code, or a local get_asset_lineage next to montecarlo__getAssetLineage, which matches the server's get_asset_lineage). Names are compared ignoring case, _ and -. abt compile fails on it; keep one of the two. For an agent dup that lists a local search_code and github__search_code:
ERROR: These tools would reach the model under the same name (MCP tools drop their '<source>__' prefix): dup: 'github__search_code' and 'search_code'. Keep one of each.

source__* is only expanded under abt compile --live, which asks the servers for their tools; otherwise such a collision fails when the agent is built.

Schema sanitization

MCP tool schemas are normalized at load time: additionalProperties is set to false on all object-type schemas. This prevents providers (notably Bedrock) from rejecting schemas or inflating constrained-decoding grammars.

To disable (rare): set flags.sanitize_mcp_schemas: false in abt.yaml. See Configuration — MCP tool schema sanitization.

JSON shape

Each file is one server, and the source name is the file's stem (mcps/github.json → github). The file holds the server's connection object directly. The mcpServers wrapper that other MCP clients use is rejected:

- github: 1 validation error for McpSourceJson
mcpServers
  Extra inputs are not permitted [type=extra_forbidden, ...]

The accepted keys are command, args, env, url, headers and type. Any other key (transport, cwd, timeout, description, ...) fails the same way. A stdio server takes command (+ args, env); an HTTP server takes url (+ headers). type (stdio or http) is optional: abt infers it from command or url, and a file with neither fails with unable to infer transport; provide 'type' or one of 'url'/'command'. You can use {{ env_var('NAME') }} / {{ env_var('NAME', 'default') }} calls in strings; they are resolved by abt compile and when the source is used, from environment variables — including values published from profiles.yaml → env:.

stdio example (mcps/github.json); it needs Node.js, with npx on PATH:

{
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-github"],
  "env": {
    "GITHUB_PERSONAL_ACCESS_TOKEN": "{{ env_var('MCP_GITHUB_TOKEN') }}"
  }
}

Without npx, abt compile --live fails as below (abt doctor does not check), and a run logs Failed to load github tools and starts without them:

ERROR: MCP tool validation failed:
- MCP source 'github': tool discovery failed — ExceptionGroup:  (1 sub-exception) (env: MCP_GITHUB_TOKEN)

HTTP example (mcps/docs_search.json):

{
  "url": "https://mcp.example.com/mcp",
  "headers": {
    "Authorization": "Bearer {{ env_var('DOCS_MCP_TOKEN') }}"
  }
}

Set MCP_GITHUB_TOKEN under the target's env: in profiles.yaml (a top-level env: is ignored):

default:
  target: dev
  outputs:
    dev:
      model_id: openai:gpt-4.1-mini
      env:
        MCP_GITHUB_TOKEN: ghp_xxxxxxxx

Or rely on the process environment in production (often with env_var('NAME') — no default — only).

env_var('NAME') with no default needs NAME set, in profiles.yaml → env: or the process environment, before any run that uses the source. manifest.json and the docs site show a source's url as written, with env_var() calls unrendered, so a credential in a URL never reaches an artifact. A plugin-registered source shows a url only if it sets url_template.

Tuning (timeouts, cache)

Project-level knobs live under abt.yaml → config: and map to ProjectConfig, for example:

  • mcp_tool_cache_ttl_seconds
  • mcp_source_max_concurrency
  • mcp_get_tools_timeout_seconds
  • mcp_get_tools_retries
  • mcp_get_tools_retry_base_ms

mcp_source_max_concurrency is capped by the global --threads budget (default 4) so one rogue config cannot saturate the event loop. See Configuration for the full list and defaults.

End-to-end example: GitHub search agent

1. mcps/github.json

{
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-github"],
  "env": {
    "GITHUB_PERSONAL_ACCESS_TOKEN": "{{ env_var('GITHUB_TOKEN') }}"
  }
}

2. Set the token in profiles.yaml

default:
  target: dev
  outputs:
    dev:
      model_id: bedrock_converse:your-model-id
      env:
        GITHUB_TOKEN: ghp_xxxx   # or use env_var('GITHUB_TOKEN') to read it straight from the environment

3. agents/github-investigator.md

---
name: github-investigator
description: Searches code and pull requests on GitHub.
tools:
  - github__search_code
  - github__list_pull_requests
---

You investigate code changes and pull requests. Search for relevant code
before drawing conclusions.

4. Run

abt compile --project-root .
abt run -s github-investigator -p "What changed in the auth module last week?" --project-root .

Plugin-registered sources (abt.mcp_loaders)

Static JSON files under mcps/ cover the common case. For an MCP source that shouldn't be checked into the repo at all (an ephemeral or per-developer server), register it dynamically via the abt.mcp_loaders entry-point group instead:

# my_pkg/mcp_loaders.py
import os
from pathlib import Path
from typing import Any
from abt.mcps.registry import MCPSourceConfig

class EnvMcpLoader:
    def load(self, *, config: dict[str, Any], project_root: Path) -> MCPSourceConfig | None:
        url = os.environ.get("EXAMPLE_MCP_URL", "").strip()
        if not url:
            return None
        return MCPSourceConfig(name="env_mcp", transport="http", client_config={"url": url})

env_mcp_loader = EnvMcpLoader()
[project.entry-points."abt.mcp_loaders"]
env_mcp = "my_pkg.mcp_loaders:env_mcp_loader"

Return None from load() to contribute nothing (e.g. the env var isn't set) — the loader is skipped without error.

client_config takes url (+ headers, timeout, sse_read_timeout, a bearer-token auth) for http and sse, or command (+ args, env, cwd) for stdio. transport (http, sse or stdio) may be omitted (inferred from url / command). The protocol handshake is negotiated automatically on every connect (modern and classic initialize servers both work). WebSocket is not supported. Any other key is logged as ignored.

See also

  • Subagents — listing MCP tools on specialist agents