Metadata-Version: 2.5
Name: mcp-intent
Version: 0.1.1
Summary: Intent-first entry tool and intent analytics for MCP servers
Project-URL: Homepage, https://vindler.solutions/mcp-intent
Project-URL: Repository, https://github.com/vindler-solutions/mcp-intent
Project-URL: Issues, https://github.com/vindler-solutions/mcp-intent/issues
Author-email: Vindler Solutions <contact@vindler.solutions>
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: agents,fastmcp,intent,mcp,mcp-sdk,model-context-protocol,opentelemetry
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx2>=2.10
Requires-Dist: opentelemetry-api>=1.30
Requires-Dist: pyyaml>=6
Provides-Extra: anthropic
Requires-Dist: anthropic>=2.14; extra == 'anthropic'
Provides-Extra: fastmcp
Requires-Dist: fastmcp<5,>=4.2; extra == 'fastmcp'
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2.3; extra == 'mcp'
Description-Content-Type: text/markdown

# mcp-intent

[![PyPI](https://img.shields.io/pypi/v/mcp-intent)](https://pypi.org/project/mcp-intent/)
[![npm](https://img.shields.io/npm/v/mcp-intent)](https://www.npmjs.com/package/mcp-intent)
[![Python](https://img.shields.io/pypi/pyversions/mcp-intent)](https://pypi.org/project/mcp-intent/)
[![CI](https://github.com/vindler-solutions/mcp-intent/actions/workflows/ci.yml/badge.svg)](https://github.com/vindler-solutions/mcp-intent/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/vindler-solutions/mcp-intent/blob/main/LICENSE)
[![mcp-intent Cloud](https://img.shields.io/badge/Cloud-free%20beta-00B4D8)](https://app.mcp-intent.com)

An intent-first entry tool for MCP servers.

An agent connecting to your MCP server sees a list of tools and guesses how to use them. Your
company rules (which warehouse serves which customer, when a refund becomes store credit, what
needs a manager's approval) are usually nowhere it can see. With `mcp-intent`, the agent's first
call states what it is trying to do, and your server answers with the steps and the rules for that
kind of task. The stated task is also a record of what people come to your server to do.

Your other tools are not touched: nothing is injected into their schemas, and the handle the entry
tool returns is never required anywhere.

## Install

mcp-intent works with the main MCP server libraries in Python, TypeScript and Go. Each package
follows the same specification (`docs/spec.md`) and is tested against the same cases.

| Your server is built with | Install |
|---|---|
| FastMCP 4 (Python) | `pip install "mcp-intent[fastmcp]"` |
| The official MCP Python SDK (`MCPServer`) | `pip install "mcp-intent[mcp]"` |
| The official TypeScript SDK, v1 or v2 | `npm install mcp-intent` (see `typescript/README.md`) |
| The official Go SDK | `go get github.com/vindler-solutions/mcp-intent/go` (see `go/README.md`) |

Add `anthropic` to the Python extras (`mcp-intent[fastmcp,anthropic]`) for the Claude-based
router.

## Use

```python
from fastmcp import FastMCP
from mcp_intent import Guidance, add_entry_tool

mcp = FastMCP("shop", instructions="Shop back office.")
# ... your tools ...
add_entry_tool(mcp, Guidance.from_yaml("guidance.yaml"))
```

The same call works on the official SDK's `MCPServer`. `MCPServer` takes its instructions only at
construction, so build it with `instructions=entry_instructions("Shop back office.")`;
`add_entry_tool` refuses to start without that sentence unless you pass `point_instructions=False`:

```python
from mcp.server.mcpserver import MCPServer
from mcp_intent import Guidance, add_entry_tool, entry_instructions

mcp = MCPServer("shop", instructions=entry_instructions("Shop back office."))
add_entry_tool(mcp, Guidance.from_yaml("guidance.yaml"))
```

On any other framework, build an `EntryTool` and register `await entry.call(task, client)` as a
tool yourself; `docs/spec.md` lists what the tool must look like.

`guidance.yaml` lists task families with the steps for each, and rules tagged with the families
they apply to:

```yaml
families:
  refund:
    when: a customer wants money back for an order
    keywords: [refund, money back, damaged, broken]
    steps: |
      1. get_order to read the lines and the order date.
      2. Refund only the lines the customer reports.
rules:
  - text: Orders placed more than 90 days ago are settled as store credit, never refunded in money.
    families: [refund]
fallback: |
  Read the relevant records before changing anything.
```

The agent calls `start_task` with one sentence. A router picks the family; the tool returns that
family's steps, the rules tagged for it, and a handle. If nothing matches, the router fails, or it
takes longer than the timeout (3 seconds by default), the tool returns `fallback`.

Runnable examples: `examples/shop/` (FastMCP), `examples/sdk/` (official SDK),
`typescript/examples/` and `go/examples/`.

## Routers

- `KeywordRouter` (default): free and deterministic. It needs `keywords` on every family and
  refuses to start without them, because family descriptions alone route poorly (5 of 16 prompts
  in our benchmark).
- `AnthropicRouter` (`mcp_intent.anthropic_router`): asks Claude Haiku 5.5 to pick the family.
  It routed all 16 benchmark prompts correctly, in about half a second and a few hundred input
  tokens a call. Reads `ANTHROPIC_API_KEY`.
- `CloudRouter`: routes on mcp-intent Cloud with a Cloud key, so the server needs no model key.
  Opt-in; it sends the task sentence and the families' names, descriptions and keywords (never
  steps or rules).
- Your own: any object with `async def route(self, task, guidance) -> str | None`.

```python
from mcp_intent.anthropic_router import AnthropicRouter

add_entry_tool(mcp, guidance, router=AnthropicRouter())
```

## What it does to your server

- Adds one tool, `start_task` (name configurable), marked read-only and
  `anthropic/alwaysLoad` so hosts that defer tool definitions still show it at session start.
- Puts one sentence pointing at it at the start of your server instructions. Hosts cut
  instructions short (Claude Code keeps 4,096 characters), so the pointer goes first. Turn it off
  with `point_instructions=False`.
- Calls `on_intent(event)` after every entry call, if you pass it: the task, the family, the
  handle, latency, and whether it fell back. Use it to log or count intents.
- Adds `mcp_intent.*` attributes to the current OpenTelemetry span, so intents show up in the
  tracing you already run. The task text is included unless `record_task_in_span=False`.
- Sends nothing anywhere unless you set a Cloud API key.

## mcp-intent Cloud (beta)

Set an API key from [app.mcp-intent.com](https://app.mcp-intent.com) and the package sends each
intent to a hosted dashboard: what agents come to do, by family and by host, the tasks no family
matched, and a CSV export.

```bash
export MCP_INTENT_API_KEY=mi_live_...
```

or `add_entry_tool(mcp, guidance, cloud_key="mi_live_...")`. A key alone never moves routing off your server. To route
on the Cloud without a model key of your own, opt in with
`add_entry_tool(mcp, guidance, router=CloudRouter())`; if the Cloud is slow or down, keyword
routing answers that call, so give your families keywords either way. Events are batched and sent in the
background; if the Cloud is slow or down, your agents still get their answer and the failure is
logged. `send_task_text=False` keeps task sentences on your side. Nothing is sent without a key.

With a key, the package also records each tool call and tool listing: the tool's name, timing,
the host, and hashed session signals, never the arguments or results. The Cloud uses them to show
coverage, the share of agent sessions that stated an intent, and what the other sessions most
likely came to do. `record_calls=False` turns this off.
On shutdown, `await entry.aclose()` (the `EntryTool` that `add_entry_tool` returns) sends what
is still queued.

## Need it inside your company?

If you need mcp-intent running entirely in your own infrastructure, behind an MCP gateway, on a
framework the packages do not cover yet, or with guidance written and measured on your own tasks, Vindler
builds that as a project. We write the guidance with your team, run the same benchmark on your
server across the hosts your users come from, and leave you with the numbers.
[Talk to us](https://vindler.solutions/hire/mcp-a2a-developers?utm_source=github&utm_medium=referral&utm_campaign=oss-mcp-intent).

## Contributing

mcp-intent is actively maintained by the Vindler team and the community, and contributions are
welcome. The most useful thing you can send us is an issue: a host that does not call the entry
tool, a router that picks the wrong family, a framework you would like supported, or anything in
this README that did not match what you saw. [Open an issue](https://github.com/vindler-solutions/mcp-intent/issues)
with the host and model you used and, if you can, the task sentence the agent sent.

Pull requests are welcome too. For anything beyond a small fix, open an issue first so we can agree
on the approach. A change to behaviour goes into `docs/spec.md` and `spec/fixtures/` first, then
into all three packages. Before you push, run the same checks as CI:

```bash
uv sync --group dev
uv run ruff check . && uv run ruff format --check . && uv run mypy src && uv run pytest
(cd typescript && pnpm install && pnpm typecheck && pnpm test)
(cd go && go vet ./... && go test -race ./...)
```

Every change adds a line to `CHANGELOG.md`. Security problems go to contact@vindler.solutions,
not to a public issue.

## Licence

Apache-2.0. See `LICENSE` and `NOTICE`.

Maintained by [Vindler Solutions](https://vindler.solutions/?utm_source=github&utm_medium=referral&utm_campaign=oss-mcp-intent).
