feat(build): install stdio MCP tool packages when the image is built
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- build-system, infrastructure
Direzione di ricerca
Start with pkg/agentkit/config/tool.go and validate.go, then read pkg/agentkit2llb/agent/convert.go and image.go to trace validation and image construction. Run the Go tests in pkg/agentkit/config and pkg/agentkit2llb/agent; add coverage for the specified validation and install behavior, then build the packaged-tools fixture and verify it starts with --network none. Done means both tools start offline, invalid package values fail clearly, and the docs are updated.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Most stdio MCP tools are started with uvx or npx:
tools:
- name: fetch
command: ["uvx", "mcp-server-fetch"]
The built image doesn't contain mcp-server-fetch. Each time a container starts, uvx downloads it and its dependencies from PyPI. npx does the same from npm. This causes four problems:
- Slow start. The first boot waits for downloads. The README even tells people to raise
AGENTKIT_MCP_TIMEOUTto 180 seconds. - No internet means no tools. Containers on locked-down clusters or offline networks can't start their tools.
- The code can change between starts. Without a pinned version, each start can pick up a newer release. Two containers from the same image can run different tool code. A bad or compromised release reaches running agents without anyone rebuilding.
- Image scanners and signatures miss it. They only cover what's inside the image, and the tool code isn't.
What
Add an optional package field to stdio tools. When it's set, AgentKit installs that exact version into the image at build time. The container then runs the installed program without downloading anything.
tools:
- name: fetch
package:
pypi: mcp-server-fetch==<version>
command: ["mcp-server-fetch"]
- name: everything
package:
npm: "@modelcontextprotocol/server-everything@<version>"
command: ["mcp-server-everything"]
pypiandnpmare the two sources. They match theuvxandnpxlaunchers the runtime images already include.- The version must be exact:
==1.2.3for PyPI,@1.2.3for npm. Version ranges and tags such aslatestfail the build. - Tools without
packagekeep working exactly as they do today. /agent/agent.yamldoesn't change. The runtime runscommandthe same way as now; the program is simply already installed.
Out of scope
- Downloading plain binaries with checksums. #43 (
kind: Toolbox) covers that, and the download code could be shared later. - Lock files or hashes for dependencies. The tool's own version is pinned. Its dependencies are picked at build time and then fixed inside the image. Pinning them too can come later.
- Private package indexes that need credentials. This would need BuildKit build secrets, so it's left for later.
- Rejecting
uvxornpxtools that have nopackage. They keep working, and the docs recommendpackage.
Why
- Agents start in seconds and work without internet access.
- Every container from the same image runs the same tool code.
- Image scanners and signatures cover the tools too.
- This is the point of AgentKit: one image that holds everything the agent needs except secrets.
How
Where things are
| File | What it does |
|---|---|
pkg/agentkit/config/tool.go |
The Tool struct. Add the new field here. |
pkg/agentkit/config/validate.go |
Tool checks: validateToolTransport, validateToolEnv and others. |
pkg/agentkit/effective/agent.go |
Copies the config into the build-ready agent. Check that the new field is copied too. |
pkg/agentkit2llb/agent/convert.go |
Builds the image. Today it starts from the runtime image and writes /agent/agent.yaml. Add the install steps here. |
pkg/agentkit2llb/agent/image.go |
Image settings such as PATH. Tests are in image_test.go. |
pkg/agentkit/abi/render.go |
Writes /agent/agent.yaml. Don't add package there. |
runtimes/*/Dockerfile |
All three runtime images already include uv, node and npm. |
Steps
- Schema. Add
Package *ToolPackagetoTool, whereToolPackagehas two fields:PyPI string(yaml:"pypi,omitempty") andNPM string(yaml:"npm,omitempty"). - Validation. Each of these rules fails the build with a clear message:
packageis allowed only on stdio tools, meaningcommandis set. Remote tools can't use it.- Set exactly one of
pypiornpm. - The version must be exact:
- PyPI:
name==version. Extras such asname[extra]==versionare fine. - npm:
name@versionor@scope/name@version, where the version is a plain number such as1.2.3. - Reject ranges, tags, URLs, git sources and file paths.
- Use a strict pattern, because this text ends up in a build command.
- PyPI:
- When
packageis set,command[0]can't beuvx,uv,npxornpm. Example message:this tool is installed when the image is built; run its program directly, e.g. command: ["mcp-server-fetch"].
- Build. In
convert.go, add one install step per packaged tool on top of the runtime image, beforeagent.yamlis written:- PyPI:
uv tool install <spec>, with these environment variables:UV_TOOL_DIR=/opt/agentkit-tools/uvUV_TOOL_BIN_DIR=/opt/agentkit-tools/binUV_PYTHON_DOWNLOADS=never, so uv uses the image's Python 3.12 instead of downloading another one.
- npm:
npm install --global --prefix /opt/agentkit-tools <spec>. The programs end up in/opt/agentkit-tools/bin. - Pass the command as a list with
llb.Args(...), never as one shell string. - Run the install as root. The agent runs as user 1000, so it can run the tools but can't change them.
- In a multi-platform build, the step runs once per platform, so each platform gets its own native files.
- If
uvornpmis missing from the base image, fail with a clear message. That could happen once #52 lets people bring their own base image.
- PyPI:
- PATH. In
image.go, add/opt/agentkit-tools/binto the end ofPATH.- Tool processes already get
PATHfrom the server. That's howuvxandnpxare found today. Socommand: ["mcp-server-fetch"]should work without other changes. - Add a test that confirms this.
- Tool processes already get
- No runtime change. Don't write
packageinto/agent/agent.yaml, so the Python side doesn't need to change. If you decide it should be written there, note that the Python reader (runtimes/common/agentkit_serve_common/config.py) rejects unknown fields and would need updating.
Tests
- Go unit tests in
pkg/agentkit/configfor each validation rule. - A Go test in
pkg/agentkit2llb/agentthat checks:- each packaged tool gets an install step with the exact arguments;
- tools without
packageget no install step; PATHincludes/opt/agentkit-tools/bin.
- A container test:
- Add a fixture
test/agentkitfile-packaged-tools.yamlwith one PyPI tool and one npm tool. - Build it and run it with
docker run --network none. - Check that
/healthzreturns 200 from inside the container, for example withpython -candurllib. Tools start before the server accepts requests, so a 200 shows both tools started with no network. - Add this check to the Docker job in
.github/workflows/ci.yml, next to the existing fixture smoke tests. Run actionlint after editing workflows (seeAGENTS.md).
- Add a fixture
Run:
go test ./...
make lint
Docs
docs/agentkitfile.md: documentpackagewith the examples and rules above.README.md, in "Add MCP tools": showpackageas the recommended option and keep plainuvxas the quick one. Update the slow-first-boot note.
Done when
- An agent with one PyPI tool and one npm tool builds, and its container starts with
--network nonewith both tools ready. - Each invalid
packagevalue fails the build with a clear message. - A second build of the same file reuses the cached install step.
- Tools without
packagework exactly as before. - The docs explain
packageand recommend it.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 5
- Merge medio
- 3h 39m
- PR unite (30g)
- 1
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Forse già presa @gambtho l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
orka-agents/agentkit#77 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
orka-agents/agentkit#76 · 3 commenti ·
-
area/build area/orka area/runtime blocked enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
orka-agents/agentkit#65 ·
Tutte le issue di orka-agents/agentkit
Issue simili
-
bot-triaged module: correctness (silent) module: fft triage review
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Remove Python pin in recipeAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
conda-forge/zarpaint-feedstock#8 · 1 commento · 1 reazione ·
-
plot_prediction colorbar shows a 0-1 range instead of the data rangeForse già presa @nikhil3495 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mllam/neural-lam#902 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
didi/helixharness#28 ·
I maintainer di solito rispondono entro 1 giorno
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno