agent-as-model
A true MCP server where the agent is the model and the API key.
mcp-name: io.github.fernandogarzaaa/agent-as-model
Install
uvx agent-as-model
Claude Code:
claude mcp add agent-as-model -- uvx agent-as-model
Any client that takes MCP JSON, paste this:
{
"mcpServers": {
"agent-as-model": {
"command": "uvx",
"args": ["agent-as-model"]
}
}
}
Requires Python 3.10+ and a host that declares the MCP sampling
capability. No API keys, ever.
From a local checkout: python -m agent_as_model. From the repo
without installing: uvx --from git+https://github.com/fernandogarzaaa/agent-as-model agent-as-model.
The idea
AI products usually demand a model API key before they do anything useful. This server flips that around. The tools speak the request shapes products already use, and the intelligence comes from the agent on the other end of the MCP connection. The agent is the model. The agent is the key.
Tools
chat_complete — OpenAI chat-completions-shaped request, completion text back.
{
"messages": [
{"role": "system", "content": "You are terse."},
{"role": "user", "content": "Explain MCP sampling."}
],
"model": "agent-default",
"temperature": 0.7,
"max_tokens": 500
}
messages_create — Anthropic messages-shaped request, completion text back.
system accepts a string or a list of text blocks. Message content accepts a
string or a list of text blocks.
list_models — returns the one model this server offers: agent-default,
an alias for the host agent's own model.
How it works
- A product (or agent) calls
chat_completewith ordinary chat messages. - The server translates them into MCP sampling messages and asks the host
to complete them. On pre-2026 connections this is a direct
sampling/createMessagerequest. On 2026-07-28+ it rides the multi-round-trip pattern. One tool body serves both eras. - The host agent generates the completion with its own model and the server
returns the text. The
modelargument is passed to the host as a model hint only;agent-defaultmeans "your own model".
Honest caveats
- Sampling is deprecated upstream (SEP-2577, spec 2026-07-28, earliest removal 2027-07-28). The official migration path is provider API keys. This project exists because the agent-as-model architecture is the point, not the keys. The era-portable form used here is the sanctioned way to keep it working across both spec eras.
- The host is in charge. Sampling runs under the host's consent and policy.
A host without the sampling capability gets a clear
MISSING_REQUIRED_CLIENT_CAPABILITYerror, not a silent failure. - Latency is one host model call per tool call. This is a thinking endpoint, not a fast one.
- v1 serves text only. Tool calls, images, and audio in either direction are rejected with explicit errors, not silently dropped.
Roadmap
- Provider-key fallback for hosts without sampling (opt-in, per-call choice stays with the user).
- Structured output passthrough where hosts support it.
- More product shapes as tools (embeddings-shaped requests cannot be sampled meaningfully; out of scope by design).
Development
python3 -m pytest tests/ -q
python3 -m ruff format . && python3 -m ruff check .
14 tests, all green: message translation unit tests plus end-to-end runs of the full MCP loop (tool call to sampled completion) against a scripted host on both the modern multi-round-trip era and the legacy direct-sampling era.
Metadata
Release files for agent-as-model 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agent_as_model-0.1.2.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agent_as_model-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / agent_as_model-0.1.2.tar.gz
| Download URL | agent_as_model-0.1.2.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37b48a1ee625224e245673a05a238153e2db91d0aca4743d6eda4d853f5208a8
|
|
BLAKE2b-256 checksum How to use checksums |
4b7d432f62a1b3ef7f47b8d8bb02e162de0828b13eb8612e6dc19b57c71b8d0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 18, 2026.
Transparency logRelease files / agent_as_model-0.1.2-py3-none-any.whl
| Download URL | agent_as_model-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9906554b326e4f80858e2fc98e0a3c3b1c55f81ae1d7d54c81bbc002a1be6409
|
|
BLAKE2b-256 checksum How to use checksums |
25ee77f835012f1a1d911a176ca5b7912bb0014d32d2d3b0ce3dfbfdd91682dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 18, 2026.
Transparency log