maco
Connect every MCP server you need, keeping your agent's context lean.
https://github.com/user-attachments/assets/4b91ea97-d48e-41c5-8189-0da8522ac459
As the number of MCP servers you connect grows, tool schemas and intermediate tool call results clutter your agent's context. maco (mcp-as-code) collapses them all into a single endpoint with a programmatic interface.
Instead of loading hundreds if not thousands of tool schemas upfront, maco reconstructs every MCP tool as Pydantic models and Python functions in a virtual filesystem and hands your agent just two of its favourite tools: bash to navigate, and code_execute to run. The agent discovers and composes tools as code, the thing frontier models do best.
How it works
Small context footprint: the agent starts with two tools (bash and code_execute), not every MCP tool schema upfront.
Progressive discovery: frontier models excel at navigating filesystems. By representing the tool interface as code on a filesystem, the agent can leverage rg, fd and all the POSIX tools to discover and execute relevant MCP tools.
tools
├── playwright
│ ├── browserClick.py
│ ├── browserClose.py
│ ├── ... many other tools
│ └── __init__.py
└── github
├── addIssueComment.py
└── __init__.py
Programmatic leverage: the agent is given a real programming language, Python, allowing it to orchestrate complex control flows with exceptional context-efficiency using loops, conditions, and state management.
import asyncio
from collections import Counter
from tools.github import ListCommitsInput, list_commits
async def main():
owner, repo, page, counts = "openclaw", "openclaw", 1, Counter()
while True:
commits = await list_commits(ListCommitsInput(owner=owner, repo=repo, per_page=100, page=page))
for commit in commits:
login = (commit.get("author") or {}).get("login")
if login and "bot" not in login.lower():
counts[login] += 1
if len(commits) < 100 or page >= 20:
break
page += 1
total = sum(counts.values())
for login, count in counts.most_common():
if count / total < 0.01:
break
print(f"@{login}: {count} commits ({count / total:.1%})")
asyncio.run(main())
The example above illustrates the MCP code that will be executed to find the top contributors to an open-source repository.
Installation
Install the Python package mcp-as-code; it provides the maco executable:
uv tool install mcp-as-code
To use the Matchlock sandbox provider, install the optional Matchlock support instead:
uv tool install 'mcp-as-code[matchlock]'
The Matchlock binary must also be installed and available on PATH.
Then verify the CLI:
maco version
Quick start
Create a mcp.json:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"]
},
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": { "Authorization": "Bearer ${GITHUB_TOKEN}" }
}
}
}
This config needs npx (for Playwright MCP), a GitHub token in GITHUB_TOKEN, and Docker if you use the docker provider.
Start the maco MCP server:
maco up --config mcp.json --provider docker
Use --provider local for a faster, non-isolated local feedback loop.
By default this serves Streamable HTTP MCP at http://127.0.0.1:8789/mcp.
Configure an MCP client to connect to that endpoint:
Codex
codex mcp add maco --url http://127.0.0.1:8789/mcp
Claude Code
claude mcp add --transport http maco http://127.0.0.1:8789/mcp
See examples/serve-mcp for a complete example that wraps multiple upstream MCP servers behind one maco endpoint.
MCP config
See docs/mcp-config.md for the full config reference, including environment expansion, headers, OAuth hints, token caching, and tool filtering.
Sandbox providers
Choose the execution provider with --provider:
local: ideally for local development and fast feedback loop, or maco is already running in an isolated sandbox.docker: runs mcp bash and code execution in a long-lived Docker container.matchlock: runs mcp bash and code execution in a long-lived Matchlock micro-VM; requiresmcp-as-code[matchlock]and the Matchlock binary.
Credits
maco is inspired by and builds on ideas from:
License
Apache License 2.0. See LICENSE.
Metadata
Release files for mcp-as-code 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcp_as_code-0.1.7.tar.gz | 51.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_as_code-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 111.8 kB
Release files / mcp_as_code-0.1.7.tar.gz
| Download URL | mcp_as_code-0.1.7.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d137ddd68923af9dffb5e67f2466f310f3f3de7cbc9ee85374e8765eb15963a6
|
|
BLAKE2b-256 checksum How to use checksums |
68e753b7db69b50799c22739715c5f5e7890b6306c710f5eb65839ed2332882a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.
Transparency logRelease files / mcp_as_code-0.1.7-py3-none-any.whl
| Download URL | mcp_as_code-0.1.7-py3-none-any.whl |
|---|---|
| Size | 60.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d8a225576820e6139f852511b26689880c8b8351d5383e0c905ebd48a8431df
|
|
BLAKE2b-256 checksum How to use checksums |
7a72fef9cbe46bb7da4f4814eba23f5ef44dfe6d38737402fec644909a87ebc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.
Transparency log