Skip to main content

agent-as-model

A true MCP server where the agent is the model and the API key.

Install it on any MCP host (Claude Code, Cursor, Windsurf, any spec-compliant client). It exposes product-style completion tools. Every call is fulfilled by sampling the host agent's own LLM. No API keys exist anywhere in this system.

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.

Install

Requires Python 3.10+ and a host that declares the MCP sampling capability. No API keys, ever.

Run it straight from the repo with uvx (no install step):

claude mcp add agent-as-model -- uvx --from git+https://github.com/fernandogarzaaa/agent-as-model agent-as-model

Or install it for real:

pipx install git+https://github.com/fernandogarzaaa/agent-as-model
# then
claude mcp add agent-as-model -- agent-as-model

Cursor, Windsurf, or any client that takes MCP JSON:

{
  "mcpServers": {
    "agent-as-model": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/fernandogarzaaa/agent-as-model", "agent-as-model"]
    }
  }
}

From a local checkout: python -m agent_as_model.

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

  1. A product (or agent) calls chat_complete with ordinary chat messages.
  2. The server translates them into MCP sampling messages and asks the host to complete them. On pre-2026 connections this is a direct sampling/createMessage request. On 2026-07-28+ it rides the multi-round-trip pattern. One tool body serves both eras.
  3. The host agent generates the completion with its own model and the server returns the text. The model argument is passed to the host as a model hint only; agent-default means "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_CAPABILITY error, 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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-as-model 0.1.0
File Size Uploaded
agent_as_model-0.1.0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-as-model 0.1.0
File Interpreter ABI Platform
agent_as_model-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / agent_as_model-0.1.0.tar.gz

Download URL agent_as_model-0.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ff13773903534a7bccc8c296b114b728da083c386b8d47cfad7a1cbe63619832
BLAKE2b-256 checksum
How to use checksums
1f26c52a9c9e6e8a35ccded3f91999bccbf318eda25e1f5f6e6f4004258f346a
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

Release files / agent_as_model-0.1.0-py3-none-any.whl

Download URL agent_as_model-0.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a499b54ca3f67eac1e029d6a856711c068692c6618e301421bb3529acc95d208
BLAKE2b-256 checksum
How to use checksums
58b6c0c7aefc14155136fd0263d2c866dd1701ea3b78c9cc6e0c648bcb23acb0
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

Release history Release notifications | RSS feed

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page