mcp-intent 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_intent-0.1.0/.github/workflows/ci.yml +98 -0
- mcp_intent-0.1.0/.github/workflows/release.yml +83 -0
- mcp_intent-0.1.0/.gitignore +14 -0
- mcp_intent-0.1.0/CHANGELOG.md +56 -0
- mcp_intent-0.1.0/LICENSE +202 -0
- mcp_intent-0.1.0/NOTICE +4 -0
- mcp_intent-0.1.0/PKG-INFO +209 -0
- mcp_intent-0.1.0/README.md +177 -0
- mcp_intent-0.1.0/docs/spec.md +198 -0
- mcp_intent-0.1.0/examples/sdk/server.py +27 -0
- mcp_intent-0.1.0/examples/shop/guidance.yaml +23 -0
- mcp_intent-0.1.0/examples/shop/server.py +41 -0
- mcp_intent-0.1.0/go/README.md +67 -0
- mcp_intent-0.1.0/go/cloud.go +446 -0
- mcp_intent-0.1.0/go/coverage_test.go +180 -0
- mcp_intent-0.1.0/go/entry.go +313 -0
- mcp_intent-0.1.0/go/examples/shop/main.go +47 -0
- mcp_intent-0.1.0/go/go.mod +30 -0
- mcp_intent-0.1.0/go/go.sum +65 -0
- mcp_intent-0.1.0/go/guidance.go +225 -0
- mcp_intent-0.1.0/go/mcpintent_test.go +525 -0
- mcp_intent-0.1.0/go/mcpsdk.go +106 -0
- mcp_intent-0.1.0/go/routers.go +113 -0
- mcp_intent-0.1.0/go/sessions.go +137 -0
- mcp_intent-0.1.0/pyproject.toml +55 -0
- mcp_intent-0.1.0/spec/fixtures/cases.json +242 -0
- mcp_intent-0.1.0/spec/fixtures/guidance.yaml +27 -0
- mcp_intent-0.1.0/src/mcp_intent/__init__.py +34 -0
- mcp_intent-0.1.0/src/mcp_intent/adapters/__init__.py +1 -0
- mcp_intent-0.1.0/src/mcp_intent/adapters/fastmcp.py +111 -0
- mcp_intent-0.1.0/src/mcp_intent/adapters/mcpserver.py +64 -0
- mcp_intent-0.1.0/src/mcp_intent/anthropic_router.py +47 -0
- mcp_intent-0.1.0/src/mcp_intent/cloud.py +304 -0
- mcp_intent-0.1.0/src/mcp_intent/core.py +216 -0
- mcp_intent-0.1.0/src/mcp_intent/entry.py +61 -0
- mcp_intent-0.1.0/src/mcp_intent/guidance.py +115 -0
- mcp_intent-0.1.0/src/mcp_intent/options.py +40 -0
- mcp_intent-0.1.0/src/mcp_intent/py.typed +0 -0
- mcp_intent-0.1.0/src/mcp_intent/routers.py +108 -0
- mcp_intent-0.1.0/src/mcp_intent/sessions.py +110 -0
- mcp_intent-0.1.0/tests/conftest.py +91 -0
- mcp_intent-0.1.0/tests/test_cloud.py +253 -0
- mcp_intent-0.1.0/tests/test_entry.py +228 -0
- mcp_intent-0.1.0/tests/test_package.py +22 -0
- mcp_intent-0.1.0/tests/test_sessions.py +215 -0
- mcp_intent-0.1.0/typescript/.gitignore +5 -0
- mcp_intent-0.1.0/typescript/README.md +78 -0
- mcp_intent-0.1.0/typescript/examples/shop.ts +27 -0
- mcp_intent-0.1.0/typescript/package.json +65 -0
- mcp_intent-0.1.0/typescript/pnpm-lock.yaml +1776 -0
- mcp_intent-0.1.0/typescript/src/cloud.ts +304 -0
- mcp_intent-0.1.0/typescript/src/core.ts +221 -0
- mcp_intent-0.1.0/typescript/src/guidance.ts +121 -0
- mcp_intent-0.1.0/typescript/src/index.ts +243 -0
- mcp_intent-0.1.0/typescript/src/routers.ts +67 -0
- mcp_intent-0.1.0/typescript/src/sessions.ts +121 -0
- mcp_intent-0.1.0/typescript/test/cloud.test.ts +197 -0
- mcp_intent-0.1.0/typescript/test/coverage.test.ts +168 -0
- mcp_intent-0.1.0/typescript/test/entry.test.ts +198 -0
- mcp_intent-0.1.0/typescript/tsconfig.json +19 -0
- mcp_intent-0.1.0/typescript/tsconfig.test.json +5 -0
- mcp_intent-0.1.0/uv.lock +2044 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [develop, main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v6
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- run: uv sync --group dev
|
|
20
|
+
- run: uv run ruff check .
|
|
21
|
+
- run: uv run ruff format --check .
|
|
22
|
+
- run: uv run mypy src
|
|
23
|
+
- run: uv run pytest
|
|
24
|
+
|
|
25
|
+
typescript:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
defaults:
|
|
28
|
+
run:
|
|
29
|
+
working-directory: typescript
|
|
30
|
+
strategy:
|
|
31
|
+
matrix:
|
|
32
|
+
node-version: ["20", "22"]
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: pnpm/action-setup@v4
|
|
36
|
+
with:
|
|
37
|
+
package_json_file: typescript/package.json
|
|
38
|
+
- uses: actions/setup-node@v4
|
|
39
|
+
with:
|
|
40
|
+
node-version: ${{ matrix.node-version }}
|
|
41
|
+
cache: pnpm
|
|
42
|
+
cache-dependency-path: typescript/pnpm-lock.yaml
|
|
43
|
+
- run: pnpm install --frozen-lockfile
|
|
44
|
+
- run: pnpm build
|
|
45
|
+
- run: pnpm typecheck
|
|
46
|
+
- run: pnpm test
|
|
47
|
+
|
|
48
|
+
go:
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
defaults:
|
|
51
|
+
run:
|
|
52
|
+
working-directory: go
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v4
|
|
55
|
+
- uses: actions/setup-go@v5
|
|
56
|
+
with:
|
|
57
|
+
go-version-file: go/go.mod
|
|
58
|
+
cache-dependency-path: go/go.sum
|
|
59
|
+
- run: test -z "$(gofmt -l .)"
|
|
60
|
+
- run: go vet ./...
|
|
61
|
+
- run: go test -race ./...
|
|
62
|
+
|
|
63
|
+
benchmark:
|
|
64
|
+
# benchmark/ is not part of the public release, so this job is skipped there.
|
|
65
|
+
if: github.repository != 'vindler-solutions/mcp-intent'
|
|
66
|
+
runs-on: ubuntu-latest
|
|
67
|
+
defaults:
|
|
68
|
+
run:
|
|
69
|
+
working-directory: benchmark
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
- uses: astral-sh/setup-uv@v6
|
|
73
|
+
with:
|
|
74
|
+
python-version: "3.13"
|
|
75
|
+
- run: uv sync --group dev
|
|
76
|
+
- run: uv run ruff check .
|
|
77
|
+
- run: uv run ruff format --check .
|
|
78
|
+
- run: uv run pytest
|
|
79
|
+
env:
|
|
80
|
+
ANTHROPIC_API_KEY: unused
|
|
81
|
+
|
|
82
|
+
cloud:
|
|
83
|
+
# cloud/ is not part of the public release, so this job is skipped there.
|
|
84
|
+
if: github.repository != 'vindler-solutions/mcp-intent'
|
|
85
|
+
runs-on: ubuntu-latest
|
|
86
|
+
defaults:
|
|
87
|
+
run:
|
|
88
|
+
working-directory: cloud
|
|
89
|
+
steps:
|
|
90
|
+
- uses: actions/checkout@v4
|
|
91
|
+
- uses: astral-sh/setup-uv@v6
|
|
92
|
+
with:
|
|
93
|
+
python-version: "3.13"
|
|
94
|
+
- run: uv sync --group dev
|
|
95
|
+
- run: uv run ruff check .
|
|
96
|
+
- run: uv run ruff format --check .
|
|
97
|
+
- run: uv run mypy mcp_intent_cloud --ignore-missing-imports
|
|
98
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Runs on a version tag (v0.1.0). Publishes the Python package to PyPI through
|
|
4
|
+
# trusted publishing (no token is stored anywhere) and creates the GitHub
|
|
5
|
+
# release. The npm package is published from the same tag once npm trusted
|
|
6
|
+
# publishing is configured for it (repository variable NPM_TRUSTED_PUBLISHING).
|
|
7
|
+
# The Go module needs no job: it is released by the go/v0.1.0 tag itself.
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
tags: ["v*"]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
check:
|
|
15
|
+
# Releases come only from the public repository, never from the dev repo.
|
|
16
|
+
if: github.repository == 'vindler-solutions/mcp-intent'
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- name: Tag matches the package versions
|
|
21
|
+
run: |
|
|
22
|
+
tag="${GITHUB_REF_NAME#v}"
|
|
23
|
+
py=$(grep -m1 '^version' pyproject.toml | cut -d'"' -f2)
|
|
24
|
+
ts=$(node -p "require('./typescript/package.json').version")
|
|
25
|
+
echo "tag=$tag pyproject=$py package.json=$ts"
|
|
26
|
+
test "$tag" = "$py" && test "$tag" = "$ts"
|
|
27
|
+
|
|
28
|
+
pypi:
|
|
29
|
+
needs: check
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
environment:
|
|
32
|
+
name: pypi
|
|
33
|
+
url: https://pypi.org/project/mcp-intent/
|
|
34
|
+
permissions:
|
|
35
|
+
id-token: write
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
- uses: astral-sh/setup-uv@v6
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.12"
|
|
41
|
+
- run: uv build
|
|
42
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
43
|
+
|
|
44
|
+
npm:
|
|
45
|
+
needs: check
|
|
46
|
+
if: vars.NPM_TRUSTED_PUBLISHING == 'true'
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
environment:
|
|
49
|
+
name: npm
|
|
50
|
+
url: https://www.npmjs.com/package/mcp-intent
|
|
51
|
+
permissions:
|
|
52
|
+
contents: read
|
|
53
|
+
id-token: write
|
|
54
|
+
defaults:
|
|
55
|
+
run:
|
|
56
|
+
working-directory: typescript
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@v4
|
|
59
|
+
- uses: pnpm/action-setup@v4
|
|
60
|
+
with:
|
|
61
|
+
package_json_file: typescript/package.json
|
|
62
|
+
- uses: actions/setup-node@v4
|
|
63
|
+
with:
|
|
64
|
+
node-version: "22"
|
|
65
|
+
registry-url: "https://registry.npmjs.org"
|
|
66
|
+
- run: npm install -g npm@latest
|
|
67
|
+
- run: pnpm install --frozen-lockfile
|
|
68
|
+
- run: npm publish --provenance --access public
|
|
69
|
+
|
|
70
|
+
github-release:
|
|
71
|
+
needs: pypi
|
|
72
|
+
runs-on: ubuntu-latest
|
|
73
|
+
permissions:
|
|
74
|
+
contents: write
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/checkout@v4
|
|
77
|
+
- name: Release notes from the changelog
|
|
78
|
+
run: |
|
|
79
|
+
awk -v v="## ${GITHUB_REF_NAME#v} " 'index($0, v) == 1 {on=1; next} on && /^## / {exit} on {print}' CHANGELOG.md > notes.md
|
|
80
|
+
test -s notes.md
|
|
81
|
+
- run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file notes.md
|
|
82
|
+
env:
|
|
83
|
+
GH_TOKEN: ${{ github.token }}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Newest first. Versions follow semantic versioning.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (2026-12-02)
|
|
6
|
+
|
|
7
|
+
First public release: Python (`mcp-intent` on PyPI, FastMCP and official SDK adapters), TypeScript (`mcp-intent` on npm, official SDK v1 and v2) and Go (`github.com/vindler-solutions/mcp-intent/go`, official go-sdk), with a shared spec and test fixtures.
|
|
8
|
+
|
|
9
|
+
- Routing on the Cloud is opt-in: a Cloud key alone sends events but routes with the keyword
|
|
10
|
+
router on your server. Pass `CloudRouter()` to route on the Cloud. A free-tier cold start or
|
|
11
|
+
an outage used to switch routing quietly to keywords; now nothing changes routing unless you
|
|
12
|
+
choose it. A `CloudRouter` with task text kept local is refused at start.
|
|
13
|
+
- Call records in TypeScript and Go: with a Cloud key, both packages now record tool calls and
|
|
14
|
+
tool listings with hashed session signals, like the Python package, so coverage works for
|
|
15
|
+
servers on any of the three SDKs. Intent events carry the same signals. TypeScript watches
|
|
16
|
+
each connection's transport (SDK v1 and v2); Go adds receiving middleware.
|
|
17
|
+
- Session signals are harder to reverse: the salt changes every UTC day, and a client address is
|
|
18
|
+
cut to its network (/24 for IPv4, /48 for IPv6) before hashing.
|
|
19
|
+
- Multi-family routing: a compound task ("refund this, then reroute that") can be routed to up to
|
|
20
|
+
three families; the answer gives each family's steps and the rules of all of them, and events
|
|
21
|
+
carry `families`. Model routers (Claude, Cloud) use it; the keyword router stays single.
|
|
22
|
+
- Intent coverage: with a Cloud key, each tool call and tool listing is recorded (name, timing,
|
|
23
|
+
host and hashed session signals; never arguments), so the Cloud can measure how many sessions
|
|
24
|
+
stated an intent and infer what the others came to do. `record_calls=False` turns it off.
|
|
25
|
+
- The entry tool's description asks the agent to call it again when the user's task changes.
|
|
26
|
+
- The first Cloud batch carries a guidance summary: the tool names each family's steps mention.
|
|
27
|
+
|
|
28
|
+
- Cloud sink: a background sender cancelled at shutdown, or abandoned when its event loop
|
|
29
|
+
closes, no longer restarts itself or raises during cleanup. `CloudSink.aclose()` and
|
|
30
|
+
`EntryTool.aclose()` send what is queued and stop the sender.
|
|
31
|
+
- Three packages, one version: Python (FastMCP 4 and the official SDK's `MCPServer`, as extras
|
|
32
|
+
`mcp-intent[fastmcp]` and `mcp-intent[mcp]`), TypeScript for the official SDK v1 and v2 (npm
|
|
33
|
+
`mcp-intent`), Go for the official Go SDK. The Python core no longer depends on any framework;
|
|
34
|
+
`EntryTool` can be registered on any server by hand.
|
|
35
|
+
- `docs/spec.md` describes the entry tool, the event, the span attributes and the Cloud HTTP API;
|
|
36
|
+
`spec/fixtures/` holds the cases every package's tests read.
|
|
37
|
+
- Cloud clients: `flush()` waits for a send in flight and returns during an outage; an
|
|
38
|
+
unreadable routing answer falls back to keywords. A router timeout reads `after <ms> ms`.
|
|
39
|
+
`add_entry_tool` recognises subclasses of FastMCP and `MCPServer`. TypeScript `addEntryTool`
|
|
40
|
+
accepts a prebuilt `EntryTool` for per-request servers.
|
|
41
|
+
- `entry_instructions()` / `entryInstructions()` / `entry.Instructions()` for servers that take
|
|
42
|
+
instructions only at construction. Packages use public SDK API only: `MCPServer` without the
|
|
43
|
+
pointer is refused at registration; TypeScript never touches instructions and takes
|
|
44
|
+
`serverName` as an option.
|
|
45
|
+
- `add_entry_tool` registers an intent-first entry tool on a FastMCP 4 server: task families
|
|
46
|
+
with steps, tagged rules, a fallback, an optional handle, a router timeout.
|
|
47
|
+
- `Guidance` loads and validates the guidance file (YAML or a mapping).
|
|
48
|
+
- Routers: `KeywordRouter` (default, needs keywords on every family) and `AnthropicRouter`
|
|
49
|
+
(`mcp-intent[anthropic]`).
|
|
50
|
+
- `on_intent` hook and `mcp_intent.*` OpenTelemetry span attributes.
|
|
51
|
+
- Example server in `examples/shop/`.
|
|
52
|
+
- mcp-intent Cloud: `cloud_key` (or `MCP_INTENT_API_KEY`) sends intent events to the hosted
|
|
53
|
+
dashboard in the background and turns on hosted routing (`CloudSink`, `CloudRouter`);
|
|
54
|
+
`send_task_text=False` keeps task text local. Events carry the calling host.
|
|
55
|
+
- Requires Python 3.11 or later.
|
|
56
|
+
- README: badges, a Contributing section; benchmark figures moved to the published write-up.
|
mcp_intent-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
mcp_intent-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mcp-intent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Intent-first entry tool and intent analytics for MCP servers
|
|
5
|
+
Project-URL: Homepage, https://vindler.solutions/?utm_source=pypi&utm_medium=referral&utm_campaign=oss-mcp-intent
|
|
6
|
+
Project-URL: Repository, https://github.com/vindler-solutions/mcp-intent
|
|
7
|
+
Project-URL: Issues, https://github.com/vindler-solutions/mcp-intent/issues
|
|
8
|
+
Author-email: Vindler Solutions <contact@vindler.solutions>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: agents,fastmcp,intent,mcp,mcp-sdk,model-context-protocol,opentelemetry
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: httpx2>=2.10
|
|
23
|
+
Requires-Dist: opentelemetry-api>=1.30
|
|
24
|
+
Requires-Dist: pyyaml>=6
|
|
25
|
+
Provides-Extra: anthropic
|
|
26
|
+
Requires-Dist: anthropic>=2.14; extra == 'anthropic'
|
|
27
|
+
Provides-Extra: fastmcp
|
|
28
|
+
Requires-Dist: fastmcp<5,>=4.2; extra == 'fastmcp'
|
|
29
|
+
Provides-Extra: mcp
|
|
30
|
+
Requires-Dist: mcp<3,>=2.3; extra == 'mcp'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# mcp-intent
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/mcp-intent/)
|
|
36
|
+
[](https://www.npmjs.com/package/mcp-intent)
|
|
37
|
+
[](https://pypi.org/project/mcp-intent/)
|
|
38
|
+
[](https://github.com/vindler-solutions/mcp-intent/actions/workflows/ci.yml)
|
|
39
|
+
[](https://github.com/vindler-solutions/mcp-intent/blob/main/LICENSE)
|
|
40
|
+
[](https://app.mcp-intent.com)
|
|
41
|
+
|
|
42
|
+
An intent-first entry tool for MCP servers.
|
|
43
|
+
|
|
44
|
+
An agent connecting to your MCP server sees a list of tools and guesses how to use them. Your
|
|
45
|
+
company rules (which warehouse serves which customer, when a refund becomes store credit, what
|
|
46
|
+
needs a manager's approval) are usually nowhere it can see. With `mcp-intent`, the agent's first
|
|
47
|
+
call states what it is trying to do, and your server answers with the steps and the rules for that
|
|
48
|
+
kind of task. The stated task is also a record of what people come to your server to do.
|
|
49
|
+
|
|
50
|
+
Your other tools are not touched: nothing is injected into their schemas, and the handle the entry
|
|
51
|
+
tool returns is never required anywhere.
|
|
52
|
+
|
|
53
|
+
## Install
|
|
54
|
+
|
|
55
|
+
mcp-intent works with the main MCP server libraries in Python, TypeScript and Go. Each package
|
|
56
|
+
follows the same specification (`docs/spec.md`) and is tested against the same cases.
|
|
57
|
+
|
|
58
|
+
| Your server is built with | Install |
|
|
59
|
+
|---|---|
|
|
60
|
+
| FastMCP 4 (Python) | `pip install "mcp-intent[fastmcp]"` |
|
|
61
|
+
| The official MCP Python SDK (`MCPServer`) | `pip install "mcp-intent[mcp]"` |
|
|
62
|
+
| The official TypeScript SDK, v1 or v2 | `npm install mcp-intent` (see `typescript/README.md`) |
|
|
63
|
+
| The official Go SDK | `go get github.com/vindler-solutions/mcp-intent/go` (see `go/README.md`) |
|
|
64
|
+
|
|
65
|
+
Add `anthropic` to the Python extras (`mcp-intent[fastmcp,anthropic]`) for the Claude-based
|
|
66
|
+
router.
|
|
67
|
+
|
|
68
|
+
## Use
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from fastmcp import FastMCP
|
|
72
|
+
from mcp_intent import Guidance, add_entry_tool
|
|
73
|
+
|
|
74
|
+
mcp = FastMCP("shop", instructions="Shop back office.")
|
|
75
|
+
# ... your tools ...
|
|
76
|
+
add_entry_tool(mcp, Guidance.from_yaml("guidance.yaml"))
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The same call works on the official SDK's `MCPServer`. `MCPServer` takes its instructions only at
|
|
80
|
+
construction, so build it with `instructions=entry_instructions("Shop back office.")`;
|
|
81
|
+
`add_entry_tool` refuses to start without that sentence unless you pass `point_instructions=False`:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from mcp.server.mcpserver import MCPServer
|
|
85
|
+
from mcp_intent import Guidance, add_entry_tool, entry_instructions
|
|
86
|
+
|
|
87
|
+
mcp = MCPServer("shop", instructions=entry_instructions("Shop back office."))
|
|
88
|
+
add_entry_tool(mcp, Guidance.from_yaml("guidance.yaml"))
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
On any other framework, build an `EntryTool` and register `await entry.call(task, client)` as a
|
|
92
|
+
tool yourself; `docs/spec.md` lists what the tool must look like.
|
|
93
|
+
|
|
94
|
+
`guidance.yaml` lists task families with the steps for each, and rules tagged with the families
|
|
95
|
+
they apply to:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
families:
|
|
99
|
+
refund:
|
|
100
|
+
when: a customer wants money back for an order
|
|
101
|
+
keywords: [refund, money back, damaged, broken]
|
|
102
|
+
steps: |
|
|
103
|
+
1. get_order to read the lines and the order date.
|
|
104
|
+
2. Refund only the lines the customer reports.
|
|
105
|
+
rules:
|
|
106
|
+
- text: Orders placed more than 90 days ago are settled as store credit, never refunded in money.
|
|
107
|
+
families: [refund]
|
|
108
|
+
fallback: |
|
|
109
|
+
Read the relevant records before changing anything.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The agent calls `start_task` with one sentence. A router picks the family; the tool returns that
|
|
113
|
+
family's steps, the rules tagged for it, and a handle. If nothing matches, the router fails, or it
|
|
114
|
+
takes longer than the timeout (3 seconds by default), the tool returns `fallback`.
|
|
115
|
+
|
|
116
|
+
Runnable examples: `examples/shop/` (FastMCP), `examples/sdk/` (official SDK),
|
|
117
|
+
`typescript/examples/` and `go/examples/`.
|
|
118
|
+
|
|
119
|
+
## Routers
|
|
120
|
+
|
|
121
|
+
- `KeywordRouter` (default): free and deterministic. It needs `keywords` on every family and
|
|
122
|
+
refuses to start without them, because family descriptions alone route poorly (5 of 16 prompts
|
|
123
|
+
in our benchmark).
|
|
124
|
+
- `AnthropicRouter` (`mcp_intent.anthropic_router`): asks Claude Haiku 5.5 to pick the family.
|
|
125
|
+
It routed all 16 benchmark prompts correctly, in about half a second and a few hundred input
|
|
126
|
+
tokens a call. Reads `ANTHROPIC_API_KEY`.
|
|
127
|
+
- `CloudRouter`: routes on mcp-intent Cloud with a Cloud key, so the server needs no model key.
|
|
128
|
+
Opt-in; it sends the task sentence and the families' names, descriptions and keywords (never
|
|
129
|
+
steps or rules).
|
|
130
|
+
- Your own: any object with `async def route(self, task, guidance) -> str | None`.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from mcp_intent.anthropic_router import AnthropicRouter
|
|
134
|
+
|
|
135
|
+
add_entry_tool(mcp, guidance, router=AnthropicRouter())
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## What it does to your server
|
|
139
|
+
|
|
140
|
+
- Adds one tool, `start_task` (name configurable), marked read-only and
|
|
141
|
+
`anthropic/alwaysLoad` so hosts that defer tool definitions still show it at session start.
|
|
142
|
+
- Puts one sentence pointing at it at the start of your server instructions. Hosts cut
|
|
143
|
+
instructions short (Claude Code keeps 4,096 characters), so the pointer goes first. Turn it off
|
|
144
|
+
with `point_instructions=False`.
|
|
145
|
+
- Calls `on_intent(event)` after every entry call, if you pass it: the task, the family, the
|
|
146
|
+
handle, latency, and whether it fell back. Use it to log or count intents.
|
|
147
|
+
- Adds `mcp_intent.*` attributes to the current OpenTelemetry span, so intents show up in the
|
|
148
|
+
tracing you already run. The task text is included unless `record_task_in_span=False`.
|
|
149
|
+
- Sends nothing anywhere unless you set a Cloud API key.
|
|
150
|
+
|
|
151
|
+
## mcp-intent Cloud (beta)
|
|
152
|
+
|
|
153
|
+
Set an API key from [app.mcp-intent.com](https://app.mcp-intent.com) and the package sends each
|
|
154
|
+
intent to a hosted dashboard: what agents come to do, by family and by host, the tasks no family
|
|
155
|
+
matched, and a CSV export.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
export MCP_INTENT_API_KEY=mi_live_...
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
or `add_entry_tool(mcp, guidance, cloud_key="mi_live_...")`. A key alone never moves routing off your server. To route
|
|
162
|
+
on the Cloud without a model key of your own, opt in with
|
|
163
|
+
`add_entry_tool(mcp, guidance, router=CloudRouter())`; if the Cloud is slow or down, keyword
|
|
164
|
+
routing answers that call, so give your families keywords either way. Events are batched and sent in the
|
|
165
|
+
background; if the Cloud is slow or down, your agents still get their answer and the failure is
|
|
166
|
+
logged. `send_task_text=False` keeps task sentences on your side. Nothing is sent without a key.
|
|
167
|
+
|
|
168
|
+
With a key, the package also records each tool call and tool listing: the tool's name, timing,
|
|
169
|
+
the host, and hashed session signals, never the arguments or results. The Cloud uses them to show
|
|
170
|
+
coverage, the share of agent sessions that stated an intent, and what the other sessions most
|
|
171
|
+
likely came to do. `record_calls=False` turns this off.
|
|
172
|
+
On shutdown, `await entry.aclose()` (the `EntryTool` that `add_entry_tool` returns) sends what
|
|
173
|
+
is still queued.
|
|
174
|
+
|
|
175
|
+
## Need it inside your company?
|
|
176
|
+
|
|
177
|
+
If you need mcp-intent running entirely in your own infrastructure, behind an MCP gateway, on a
|
|
178
|
+
framework the packages do not cover yet, or with guidance written and measured on your own tasks, Vindler
|
|
179
|
+
builds that as a project. We write the guidance with your team, run the same benchmark on your
|
|
180
|
+
server across the hosts your users come from, and leave you with the numbers.
|
|
181
|
+
[Talk to us](https://vindler.solutions/hire/mcp-a2a-developers?utm_source=github&utm_medium=referral&utm_campaign=oss-mcp-intent).
|
|
182
|
+
|
|
183
|
+
## Contributing
|
|
184
|
+
|
|
185
|
+
mcp-intent is actively maintained by the Vindler team and the community, and contributions are
|
|
186
|
+
welcome. The most useful thing you can send us is an issue: a host that does not call the entry
|
|
187
|
+
tool, a router that picks the wrong family, a framework you would like supported, or anything in
|
|
188
|
+
this README that did not match what you saw. [Open an issue](https://github.com/vindler-solutions/mcp-intent/issues)
|
|
189
|
+
with the host and model you used and, if you can, the task sentence the agent sent.
|
|
190
|
+
|
|
191
|
+
Pull requests are welcome too. For anything beyond a small fix, open an issue first so we can agree
|
|
192
|
+
on the approach. A change to behaviour goes into `docs/spec.md` and `spec/fixtures/` first, then
|
|
193
|
+
into all three packages. Before you push, run the same checks as CI:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
uv sync --group dev
|
|
197
|
+
uv run ruff check . && uv run ruff format --check . && uv run mypy src && uv run pytest
|
|
198
|
+
(cd typescript && pnpm install && pnpm typecheck && pnpm test)
|
|
199
|
+
(cd go && go vet ./... && go test -race ./...)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Every change adds a line to `CHANGELOG.md`. Security problems go to contact@vindler.solutions,
|
|
203
|
+
not to a public issue.
|
|
204
|
+
|
|
205
|
+
## Licence
|
|
206
|
+
|
|
207
|
+
Apache-2.0. See `LICENSE` and `NOTICE`.
|
|
208
|
+
|
|
209
|
+
Maintained by [Vindler Solutions](https://vindler.solutions/?utm_source=github&utm_medium=referral&utm_campaign=oss-mcp-intent).
|