Skip to main content
Glama

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.

Related MCP server: harness_to_mcp

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.

Available Tools

3 tools
chat_completeA

Generate a chat completion from an OpenAI chat-completions-shaped request. The completion is produced by the host agent's own model via MCP sampling. No API key is used or needed: the connected agent is the model.

ParametersJSON Schema
NameRequiredDescriptionDefault
modelNoModel alias; agent-default means the host's own model.agent-default
messagesYesChat messages; system roles become the system prompt.
max_tokensNoMaximum tokens to generate.
temperatureNoSampling temperature, if the host honors it.

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it does disclose the key behavioral trait: inference runs through MCP sampling on the host agent's own model, with no API key. That is meaningful context an agent could not get elsewhere. It omits secondary traits such as sampling consent behavior or latency, keeping it below a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three tight sentences, front-loaded with the operation and immediately followed by the one fact that changes how an agent reasons about the call (the host model, no key). No padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With a full output schema and 100% parameter coverage, return values and arguments need not be described, and the description supplies the mechanism context the structured fields lack. It could say more about sampling consent/prompting, but is largely sufficient for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and every parameter (model, messages, max_tokens, temperature) is documented in the schema, including the agent-default alias. The description adds only the redundant framing that the connected agent is the model, so it does not meaningfully extend the schema. Baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (Generate) and resource (chat completion) and pins down the request shape as OpenAI chat-completions-shaped. It also names the mechanism (MCP sampling via the host agent's model), but it never explicitly distinguishes itself from the siblings messages_create or list_models, so the agent must infer the boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The note that no API key is used implies the usage context (the connected agent is the model), but there is no explicit when-to-use or when-not-to-use guidance and no routing against the sibling messages_create. Usage is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_modelsA

List the models this server offers. There is exactly one: agent-default, an alias for the host agent's own model.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden, and it does disclose non-obvious semantics: the list is fixed at one entry and that entry is an alias for the host agent's own model. It does not discuss auth or rate limits, but for a trivial read-only lister with an output schema defining the return, that gap is minor.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences, no filler, with the core purpose front-loaded before the detail about the single model. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter lister with an output schema and no annotations, the description supplies everything needed: what it returns, how many entries, and the meaning of that entry. Nothing required to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so the baseline is 4. There is nothing for the description to clarify beyond that, and it correctly presents the call as argument-free.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('List the models this server offers') and goes further by naming the single returned value, agent-default. No sibling offers model discovery, so there is no ambiguity with chat_complete or messages_create.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: an agent can infer this is for discovering available model identifiers. There is no explicit when-to-use statement, no exclusions, and no routing to an alternative. The note that only one model exists implicitly tells the agent the call is rarely needed, which is mildly useful but not structured guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

messages_createA

Generate a completion from an Anthropic messages-shaped request. The completion is produced by the host agent's own model via MCP sampling. No API key is used or needed: the connected agent is the model.

ParametersJSON Schema
NameRequiredDescriptionDefault
modelNoModel alias; agent-default means the host's own model.agent-default
systemNoSystem prompt as text or text blocks.
messagesYesUser/assistant messages in order.
max_tokensNoMaximum tokens to generate.
temperatureNoSampling temperature, if the host honors it.

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does disclose the genuinely surprising mechanic: the completion is produced by the host agent's own model via MCP sampling and no API key is involved. That is the key behavioral fact an agent would otherwise get wrong. It stops short of covering latency, determinism, or whether model/temperature are actually honored.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, each load-bearing, with the purpose front-loaded and the sampling/auth clarification immediately after. No filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained, and the description covers the unusual sampling behavior and auth model. What remains thin is the relationship to the sibling tools, which matters for selection in a three-tool space.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and every parameter (model, system, messages, max_tokens, temperature) is already documented in the schema, so baseline 3 applies. The description adds no format or naming detail beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Generate a completion') and pins down the request shape ('Anthropic messages-shaped'). It does not however differentiate itself from the sibling chat_complete, which reads superficially the same, so an agent gains no routing signal from the description alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: the 'no API key is used or needed' line suggests when this is preferable (sampling through the host agent rather than a keyed API), but there is no explicit when-to-use/when-not or comparison against chat_complete or list_models.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.1
    • First observedchat_complete
    • First observedlist_models
    • First observedmessages_create

TDQS

A3.8/5.0

Scored across 3 tools

Disambiguation4/5

chat_complete and messages_create serve genuinely distinct request shapes (OpenAI vs Anthropic schemas), and the descriptions make this clear. However, both do essentially the same thing — run a completion through the host agent — so an agent without a strong schema preference could still hesitate between them.

Naming Consistency2/5

Naming mixes conventions: 'chat_complete' is noun_verb while 'messages_create' is plural_noun_verb and 'list_models' is verb_noun. The verb position flips between first and last, and no single pattern dominates.

Tool Count4/5

Three tools are a tight, well-scoped surface for a thin model shim. The count is slightly thin but each tool earns its place; list_models is arguably redundant given the single-model aliasing, keeping it just below a 5.

Completeness4/5

The server covers the two dominant completion request shapes plus discovery, so core workflows are reachable. Minor gap: no streaming or token-counting option, and no way to introspect model capabilities, but agents can work around these.

Related MCP Connectors

Related MCP Servers