mcp-as-code 0.1.4__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/PKG-INFO +39 -24
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/README.md +36 -23
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/docs/mcp-config.md +1 -1
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/examples/serve-mcp/README.md +6 -6
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/images/sandbox/README.md +3 -3
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/pyproject.toml +3 -3
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/__init__.py +1 -1
- mcp_as_code-0.1.6/src/maco/cli.py +445 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/codegen.py +226 -80
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/gateway.py +14 -5
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/oauth.py +23 -7
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/__init__.py +1 -1
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/core.py +9 -17
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/providers/base.py +0 -1
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/serve_mcp.py +97 -97
- mcp_as_code-0.1.6/src/maco/service.py +589 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/code_execute_description.j2 +8 -1
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/codegen/client.py.j2 +37 -11
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/codegen/model.py.j2 +1 -1
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/codegen/pyproject.toml.j2 +1 -1
- mcp_as_code-0.1.6/src/maco/templates/codegen/server_init.py.j2 +12 -0
- mcp_as_code-0.1.6/src/maco/templates/codegen/tool.py.j2 +21 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/serve_mcp_instructions.j2 +7 -1
- mcp_as_code-0.1.6/src/maco/version.py +22 -0
- mcp_as_code-0.1.4/VERSION.txt +0 -1
- mcp_as_code-0.1.4/src/maco/_build_info.py +0 -4
- mcp_as_code-0.1.4/src/maco/cli.py +0 -261
- mcp_as_code-0.1.4/src/maco/templates/codegen/root_model.py.j2 +0 -3
- mcp_as_code-0.1.4/src/maco/templates/codegen/server_init.py.j2 +0 -11
- mcp_as_code-0.1.4/src/maco/templates/codegen/tool.py.j2 +0 -38
- mcp_as_code-0.1.4/src/maco/version.py +0 -72
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/.gitignore +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/LICENSE +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/config.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/mcp_manager.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/runner.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/providers/__init__.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/providers/docker.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/providers/local.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/sandbox/providers/matchlock.py +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/bash_description.j2 +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/codegen/package_init.py.j2 +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/codegen/type_alias.py.j2 +0 -0
- {mcp_as_code-0.1.4 → mcp_as_code-0.1.6}/src/maco/templates/server_catalog.j2 +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-as-code
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Execute MCP tools through generated Python code interfaces
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: click>=8.1
|
|
9
|
+
Requires-Dist: httpx>=0.28
|
|
8
10
|
Requires-Dist: jinja2>=3.1
|
|
9
11
|
Requires-Dist: matchlock==0.2.15
|
|
10
12
|
Requires-Dist: mcp>=1.24.0
|
|
@@ -15,6 +17,8 @@ Description-Content-Type: text/markdown
|
|
|
15
17
|
|
|
16
18
|
**Connect every MCP server you need, keeping your agent's context lean.**
|
|
17
19
|
|
|
20
|
+
https://github.com/user-attachments/assets/4b91ea97-d48e-41c5-8189-0da8522ac459
|
|
21
|
+
|
|
18
22
|
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.
|
|
19
23
|
|
|
20
24
|
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.
|
|
@@ -40,26 +44,30 @@ tools
|
|
|
40
44
|
**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.
|
|
41
45
|
|
|
42
46
|
```python
|
|
47
|
+
import asyncio
|
|
43
48
|
from collections import Counter
|
|
44
|
-
from tools.github import
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
from tools.github import ListCommitsInput, list_commits
|
|
50
|
+
|
|
51
|
+
async def main():
|
|
52
|
+
owner, repo, page, counts = "openclaw", "openclaw", 1, Counter()
|
|
53
|
+
|
|
54
|
+
while True:
|
|
55
|
+
commits = await list_commits(ListCommitsInput(owner=owner, repo=repo, per_page=100, page=page))
|
|
56
|
+
for commit in commits:
|
|
57
|
+
login = (commit.get("author") or {}).get("login")
|
|
58
|
+
if login and "bot" not in login.lower():
|
|
59
|
+
counts[login] += 1
|
|
60
|
+
if len(commits) < 100 or page >= 20:
|
|
61
|
+
break
|
|
62
|
+
page += 1
|
|
63
|
+
|
|
64
|
+
total = sum(counts.values())
|
|
65
|
+
for login, count in counts.most_common():
|
|
66
|
+
if count / total < 0.01:
|
|
67
|
+
break
|
|
68
|
+
print(f"@{login}: {count} commits ({count / total:.1%})")
|
|
69
|
+
|
|
70
|
+
asyncio.run(main())
|
|
63
71
|
```
|
|
64
72
|
|
|
65
73
|
The example above illustrates the MCP code that will be executed to find the top contributors to an open-source repository.
|
|
@@ -102,7 +110,7 @@ This config needs `npx` (for Playwright MCP), a GitHub token in `GITHUB_TOKEN`,
|
|
|
102
110
|
Start the `maco` MCP server:
|
|
103
111
|
|
|
104
112
|
```bash
|
|
105
|
-
maco
|
|
113
|
+
maco up --config mcp.json --provider docker
|
|
106
114
|
```
|
|
107
115
|
|
|
108
116
|
Use `--provider local` for a faster, non-isolated local feedback loop.
|
|
@@ -139,9 +147,16 @@ See [`docs/mcp-config.md`](docs/mcp-config.md) for the full config reference, in
|
|
|
139
147
|
|
|
140
148
|
Choose the execution provider with `--provider`:
|
|
141
149
|
|
|
142
|
-
- `local`:
|
|
143
|
-
- `docker`: runs
|
|
144
|
-
- `matchlock`: runs
|
|
150
|
+
- `local`: ideally for local development and fast feedback loop, or maco is already running in an isolated sandbox.
|
|
151
|
+
- `docker`: runs mcp bash and code execution in a long-lived Docker container.
|
|
152
|
+
- `matchlock`: runs mcp bash and code execution in a long-lived Matchlock micro-VM.
|
|
153
|
+
|
|
154
|
+
## Credits
|
|
155
|
+
|
|
156
|
+
`maco` is inspired by and builds on ideas from:
|
|
157
|
+
|
|
158
|
+
- [Code execution with MCP: Building more efficient agents](https://www.anthropic.com/engineering/code-execution-with-mcp)
|
|
159
|
+
- [Code Mode: the better way to use MCP](https://blog.cloudflare.com/code-mode/)
|
|
145
160
|
|
|
146
161
|
## License
|
|
147
162
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
**Connect every MCP server you need, keeping your agent's context lean.**
|
|
4
4
|
|
|
5
|
+
https://github.com/user-attachments/assets/4b91ea97-d48e-41c5-8189-0da8522ac459
|
|
6
|
+
|
|
5
7
|
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.
|
|
6
8
|
|
|
7
9
|
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.
|
|
@@ -27,26 +29,30 @@ tools
|
|
|
27
29
|
**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.
|
|
28
30
|
|
|
29
31
|
```python
|
|
32
|
+
import asyncio
|
|
30
33
|
from collections import Counter
|
|
31
|
-
from tools.github import
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
from tools.github import ListCommitsInput, list_commits
|
|
35
|
+
|
|
36
|
+
async def main():
|
|
37
|
+
owner, repo, page, counts = "openclaw", "openclaw", 1, Counter()
|
|
38
|
+
|
|
39
|
+
while True:
|
|
40
|
+
commits = await list_commits(ListCommitsInput(owner=owner, repo=repo, per_page=100, page=page))
|
|
41
|
+
for commit in commits:
|
|
42
|
+
login = (commit.get("author") or {}).get("login")
|
|
43
|
+
if login and "bot" not in login.lower():
|
|
44
|
+
counts[login] += 1
|
|
45
|
+
if len(commits) < 100 or page >= 20:
|
|
46
|
+
break
|
|
47
|
+
page += 1
|
|
48
|
+
|
|
49
|
+
total = sum(counts.values())
|
|
50
|
+
for login, count in counts.most_common():
|
|
51
|
+
if count / total < 0.01:
|
|
52
|
+
break
|
|
53
|
+
print(f"@{login}: {count} commits ({count / total:.1%})")
|
|
54
|
+
|
|
55
|
+
asyncio.run(main())
|
|
50
56
|
```
|
|
51
57
|
|
|
52
58
|
The example above illustrates the MCP code that will be executed to find the top contributors to an open-source repository.
|
|
@@ -89,7 +95,7 @@ This config needs `npx` (for Playwright MCP), a GitHub token in `GITHUB_TOKEN`,
|
|
|
89
95
|
Start the `maco` MCP server:
|
|
90
96
|
|
|
91
97
|
```bash
|
|
92
|
-
maco
|
|
98
|
+
maco up --config mcp.json --provider docker
|
|
93
99
|
```
|
|
94
100
|
|
|
95
101
|
Use `--provider local` for a faster, non-isolated local feedback loop.
|
|
@@ -126,9 +132,16 @@ See [`docs/mcp-config.md`](docs/mcp-config.md) for the full config reference, in
|
|
|
126
132
|
|
|
127
133
|
Choose the execution provider with `--provider`:
|
|
128
134
|
|
|
129
|
-
- `local`:
|
|
130
|
-
- `docker`: runs
|
|
131
|
-
- `matchlock`: runs
|
|
135
|
+
- `local`: ideally for local development and fast feedback loop, or maco is already running in an isolated sandbox.
|
|
136
|
+
- `docker`: runs mcp bash and code execution in a long-lived Docker container.
|
|
137
|
+
- `matchlock`: runs mcp bash and code execution in a long-lived Matchlock micro-VM.
|
|
138
|
+
|
|
139
|
+
## Credits
|
|
140
|
+
|
|
141
|
+
`maco` is inspired by and builds on ideas from:
|
|
142
|
+
|
|
143
|
+
- [Code execution with MCP: Building more efficient agents](https://www.anthropic.com/engineering/code-execution-with-mcp)
|
|
144
|
+
- [Code Mode: the better way to use MCP](https://blog.cloudflare.com/code-mode/)
|
|
132
145
|
|
|
133
146
|
## License
|
|
134
147
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MCP configuration
|
|
2
2
|
|
|
3
|
-
`maco` reads Claude-style MCP configuration files with a top-level `mcpServers` object. The same config is used by `maco gen
|
|
3
|
+
`maco` reads Claude-style MCP configuration files with a top-level `mcpServers` object. The same config is used by `maco gen` and `maco up`.
|
|
4
4
|
|
|
5
5
|
```json
|
|
6
6
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# `maco
|
|
1
|
+
# `maco up` example
|
|
2
2
|
|
|
3
|
-
This example shows how to expose several upstream MCP servers through one compact `maco
|
|
3
|
+
This example shows how to expose several upstream MCP servers through one compact `maco up` endpoint. The upstream servers here are:
|
|
4
4
|
|
|
5
5
|
- [Playwright MCP](https://playwright.dev/mcp/introduction), launched with `npx -y @playwright/mcp@latest`
|
|
6
6
|
- [GitHub MCP server](https://github.com/github/github-mcp-server), using GitHub's hosted Streamable HTTP endpoint at `https://api.githubcopilot.com/mcp/`
|
|
@@ -19,20 +19,20 @@ If you are already authenticated with the GitHub CLI, export a token directly:
|
|
|
19
19
|
export GITHUB_TOKEN=$(gh auth token)
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
## 1. Start `maco
|
|
22
|
+
## 1. Start `maco up`
|
|
23
23
|
|
|
24
24
|
The short path is to run from this example directory so the defaults line up with the local files:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
cd examples/serve-mcp
|
|
28
|
-
uv run maco
|
|
28
|
+
uv run maco up --provider local
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
This uses `mcp.json`, writes `.maco/gateway.json`, uses `
|
|
31
|
+
This uses `mcp.json`, writes `.maco/gateway.json`, uses `.maco/scratch` as the default scratch directory, starts the gateway, and serves HTTP MCP at `http://127.0.0.1:8789/mcp`. Add `--clean` only when you want to recreate the local generated SDK from scratch.
|
|
32
32
|
|
|
33
33
|
## 2. Connect an agent to the MCP gateway
|
|
34
34
|
|
|
35
|
-
Configure your MCP client with `mcp-client.json` to connect to `maco
|
|
35
|
+
Configure your MCP client with `mcp-client.json` to connect to `maco up`. For example, in your MCP client's settings, set the MCP server URL to `http://127.0.0.1:8789/mcp`.
|
|
36
36
|
|
|
37
37
|
If you are using codex you may connect to it via:
|
|
38
38
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# maco sandbox image
|
|
2
2
|
|
|
3
|
-
This directory contains the Docker image used by the Docker and Matchlock `maco
|
|
3
|
+
This directory contains the Docker image used by the Docker and Matchlock `maco up` sandbox providers.
|
|
4
4
|
|
|
5
5
|
The image extends the pinned Alpine uv/Python image with the `maco` CLI, `ripgrep` (`rg`), and `fd`. Remote sandbox providers use the CLI to bootstrap `/workspace/macosdk/tools` from the live gateway catalog at sandbox startup.
|
|
6
6
|
|
|
7
7
|
## Build
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
VERSION="$(
|
|
10
|
+
VERSION="$(scripts/package-version)"
|
|
11
11
|
docker build -f images/sandbox/Dockerfile -t "ghcr.io/jingkaihe/maco:${VERSION}-alpine" .
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## Import into Matchlock
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
VERSION="$(
|
|
17
|
+
VERSION="$(scripts/package-version)"
|
|
18
18
|
docker save "ghcr.io/jingkaihe/maco:${VERSION}-alpine" \
|
|
19
19
|
| matchlock image import "ghcr.io/jingkaihe/maco:${VERSION}-alpine"
|
|
20
20
|
```
|
|
@@ -6,6 +6,8 @@ readme = "README.md"
|
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
requires-python = ">=3.11"
|
|
8
8
|
dependencies = [
|
|
9
|
+
"click>=8.1",
|
|
10
|
+
"httpx>=0.28",
|
|
9
11
|
"jinja2>=3.1",
|
|
10
12
|
"matchlock==0.2.15",
|
|
11
13
|
"mcp>=1.24.0",
|
|
@@ -27,8 +29,7 @@ dev = [
|
|
|
27
29
|
]
|
|
28
30
|
|
|
29
31
|
[tool.hatch.version]
|
|
30
|
-
path = "
|
|
31
|
-
pattern = "(?P<version>.+)"
|
|
32
|
+
path = "src/maco/__init__.py"
|
|
32
33
|
|
|
33
34
|
[tool.hatch.build.targets.wheel]
|
|
34
35
|
packages = ["src/maco"]
|
|
@@ -39,6 +40,5 @@ include = [
|
|
|
39
40
|
"docs",
|
|
40
41
|
"README.md",
|
|
41
42
|
"LICENSE",
|
|
42
|
-
"VERSION.txt",
|
|
43
43
|
"pyproject.toml",
|
|
44
44
|
]
|