arbitype 0.6.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.
Files changed (47) hide show
  1. arbitype-0.6.0/.env.example +15 -0
  2. arbitype-0.6.0/BENCHMARK.md +120 -0
  3. arbitype-0.6.0/CHANGELOG.md +111 -0
  4. arbitype-0.6.0/CONTRIBUTING.md +28 -0
  5. arbitype-0.6.0/LICENSE +21 -0
  6. arbitype-0.6.0/MANIFEST.in +13 -0
  7. arbitype-0.6.0/PKG-INFO +360 -0
  8. arbitype-0.6.0/README.md +330 -0
  9. arbitype-0.6.0/SECURITY.md +33 -0
  10. arbitype-0.6.0/TESTING.md +78 -0
  11. arbitype-0.6.0/arbitype/__init__.py +26 -0
  12. arbitype-0.6.0/arbitype/__main__.py +5 -0
  13. arbitype-0.6.0/arbitype/_version.py +3 -0
  14. arbitype-0.6.0/arbitype/cli.py +125 -0
  15. arbitype-0.6.0/arbitype/core.py +728 -0
  16. arbitype-0.6.0/arbitype/mcp.py +1141 -0
  17. arbitype-0.6.0/arbitype.egg-info/PKG-INFO +360 -0
  18. arbitype-0.6.0/arbitype.egg-info/SOURCES.txt +45 -0
  19. arbitype-0.6.0/arbitype.egg-info/dependency_links.txt +1 -0
  20. arbitype-0.6.0/arbitype.egg-info/entry_points.txt +4 -0
  21. arbitype-0.6.0/arbitype.egg-info/top_level.txt +3 -0
  22. arbitype-0.6.0/docs/REGISTRY_MIGRATION.md +61 -0
  23. arbitype-0.6.0/pyproject.toml +55 -0
  24. arbitype-0.6.0/scripts/official_sdk_smoke.py +63 -0
  25. arbitype-0.6.0/scripts/release_readiness.py +189 -0
  26. arbitype-0.6.0/scripts/validate_registry_metadata.py +97 -0
  27. arbitype-0.6.0/server.json +33 -0
  28. arbitype-0.6.0/server.py +36 -0
  29. arbitype-0.6.0/setup.cfg +4 -0
  30. arbitype-0.6.0/setup.py +71 -0
  31. arbitype-0.6.0/smoke_test.py +44 -0
  32. arbitype-0.6.0/tests/test_edge_cases.py +387 -0
  33. arbitype-0.6.0/tests/test_host_integration.py +452 -0
  34. arbitype-0.6.0/tests/test_release_metadata.py +18 -0
  35. arbitype-0.6.0/tests/test_server.py +346 -0
  36. arbitype-0.6.0/typesafe_codex_mcp/__init__.py +23 -0
  37. arbitype-0.6.0/typesafe_codex_mcp/__main__.py +7 -0
  38. arbitype-0.6.0/typesafe_codex_mcp/_version.py +5 -0
  39. arbitype-0.6.0/typesafe_codex_mcp/cli.py +3 -0
  40. arbitype-0.6.0/typesafe_codex_mcp/core.py +3 -0
  41. arbitype-0.6.0/typesafe_codex_mcp/mcp.py +3 -0
  42. arbitype-0.6.0/typesafe_mcp/__init__.py +23 -0
  43. arbitype-0.6.0/typesafe_mcp/__main__.py +7 -0
  44. arbitype-0.6.0/typesafe_mcp/_version.py +5 -0
  45. arbitype-0.6.0/typesafe_mcp/cli.py +3 -0
  46. arbitype-0.6.0/typesafe_mcp/core.py +3 -0
  47. arbitype-0.6.0/typesafe_mcp/mcp.py +3 -0
@@ -0,0 +1,15 @@
1
+ # Copy these into the environment of the MCP process. Never commit a real key.
2
+ TYPESAFE_API_KEY=
3
+ # Optional overrides:
4
+ # TYPESAFE_BASE_URL=https://api.typesafe.ai
5
+ # TYPESAFE_DEFAULT_MODEL=jev-latest
6
+ # TYPESAFE_TIMEOUT_SECONDS=10
7
+ # TYPESAFE_MAX_RETRIES=2
8
+ # TYPESAFE_RETRY_BACKOFF_SECONDS=0.5
9
+ # TYPESAFE_MAX_BACKOFF_SECONDS=20
10
+ # TYPESAFE_RETRY_JITTER=0.25
11
+ # TYPESAFE_MAX_STATE_CHARS=120000
12
+ # TYPESAFE_MAX_QUESTION_CHARS=60000
13
+ # TYPESAFE_MAX_REQUEST_BYTES=512000
14
+ # TYPESAFE_MAX_RESPONSE_BYTES=4194304
15
+ # TYPESAFE_MAX_QUESTIONS=64
@@ -0,0 +1,120 @@
1
+ # Arbitype engineering comparison and verification
2
+
3
+ This document records the engineering comparison and local verification used
4
+ for the 0.6.0 release.
5
+ The repositories were inspected through their public source, documentation,
6
+ and test layouts on 2026-09-21. GitHub star counts are only a snapshot, not a
7
+ quality ranking. This project was also exercised against the real TypeSafe API
8
+ with short, controlled Jev requests; the credential was never printed or
9
+ committed.
10
+
11
+ ## Professional MCP baselines
12
+
13
+ | Project | Production practice observed | Decision for Arbitype |
14
+ | --- | --- | --- |
15
+ | [modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Official Python SDK (24k stars at review time), typed protocol surface, 2026-07-28 plus earlier revisions, stdio/Streamable HTTP/SSE, discovery, and a real `Client` | Keep the runtime dependency-free; implement dual-era STDIO negotiation, precise schemas, and run the official SDK v2 against this server in CI. HTTP remains an explicit gap |
16
+ | [PrefectHQ/fastmcp](https://github.com/PrefectHQ/fastmcp) | Mature Python framework (27k stars), server/client/app abstractions, generated schemas, auth/transports, async fixtures, typing and broad tests | Do not introduce a framework dependency for Arbitype's narrow service; adopt its contract-first schemas, bounded async/interoperability tests, and documentation discipline |
17
+ | [modelcontextprotocol/inspector](https://github.com/modelcontextprotocol/inspector) | Official web/CLI/TUI inspector (10k stars), composable test servers, smoke tests, packaging guards, and CI quality gates | Keep this repository focused on Jev; add a scriptable official-SDK smoke test that can also be driven by Inspector/MCPJam |
18
+ | [MCPJam/inspector](https://github.com/MCPJam/inspector) | Cross-client/model evals, OAuth debugging, traces, conformance checks, and CI regression gates | Arbitype exposes stable tools/output schemas for inspection, but does not pretend to replace cross-client eval or OAuth tooling |
19
+ | [snyk/agent-scan](https://github.com/snyk/agent-scan) | Explicit consent before executing discovered STDIO commands, agent config discovery, prompt-injection and secret-risk scanning, signed release artifacts | Treat this adapter as read-only and secret-conscious, but do not claim to be a supply-chain scanner; users should scan untrusted MCP configs separately |
20
+
21
+ The main trade-off is intentional: the official SDK and FastMCP provide a
22
+ broader protocol surface and stronger reusable abstractions, while Arbitype
23
+ keeps a zero-runtime-dependency footprint, a small auditable codebase, and a
24
+ focused TypeSafe tool contract. That makes it easy to start on a constrained
25
+ agent host, but means new MCP protocol features must be tracked and implemented
26
+ here instead of inherited from an SDK.
27
+
28
+ ## Capability gap matrix
29
+
30
+ | Area | Arbitype 0.6.0 | Professional baseline | Assessment |
31
+ | --- | --- | --- | --- |
32
+ | MCP protocol | 2026-07-28 modern STDIO metadata plus legacy initialize revisions; `server/discover`; version errors | Official SDK supports the current revision and earlier revisions | Strong for local STDIO; verified with the official SDK v2 |
33
+ | Transports | Newline-delimited STDIO only | Official SDK/FastMCP/Inspector support Streamable HTTP and often SSE | Deliberate limitation; remote deployment needs a separate transport layer |
34
+ | Server features | Tools only; resources/prompts are not advertised | Frameworks commonly expose tools, resources, prompts, subscriptions, elicitation | Correctly narrow for Jev; do not add unused surface just for parity |
35
+ | Schemas | Strict input validation and per-tool output schemas | Generated or typed schemas plus runtime validation | Competitive for this fixed contract |
36
+ | Reliability | Bounded retries, `Retry-After`, size limits, redaction, fail-closed provider validation | Mature projects add async cancellation, tracing, and broader fault injection | Good local reliability; cancellation/telemetry remain next steps |
37
+ | Testing | 62 offline tests, subprocess lifecycle tests, real provider check, official SDK v2 smoke in CI | Large projects add conformance suites, cross-client evals, coverage gates | Above a typical small server; not a replacement for cross-client evaluation |
38
+ | Security | Environment-only secret, read-only annotations, no file/command execution, bounded diagnostics | HTTP servers add OAuth, token audience checks, sandboxing and scanners | Safe for local STDIO; not an authenticated remote service |
39
+ | Release engineering | Matrix CI, wheel inspection, clean install, compatibility aliases | Mature projects add signed artifacts, automated publishing, dependency/update gates | Solid foundation; signed releases and registry publishing remain |
40
+
41
+ ## Jev-specific community projects previously reviewed
42
+
43
+ | Project | What it does well | What we kept out or changed |
44
+ | --- | --- | --- |
45
+ | [jkudish/jev-mcp](https://github.com/jkudish/jev-mcp) | Purpose-built tools, response validation, mock tests, useful review/gate vocabulary | It has a larger Node dependency tree; Arbitype keeps a smaller standard-library runtime and a raw API escape hatch |
46
+ | [itsmostafa/typesafe-mcp](https://github.com/itsmostafa/typesafe-mcp) | Very simple single-tool Go binary, retry and batching ideas, straightforward host setup | Go is not available on every host; Arbitype keeps a Python-only install and adds higher-level tools without hiding the raw request |
47
+ | [burnigtm/jev-mcp](https://github.com/burnigtm/jev-mcp) | Strong limits, cancellation, prepared calls, review and coding-loop policies, extensive tests | Its policy layer is intentionally opinionated and broad; Arbitype does not claim to authorize tool calls or spend on another model |
48
+ | [Brainwires/jevwire](https://github.com/Brainwires/jevwire) | A deep Claude Code harness, hooks, daemon tests, tripwires, and gate policy | Hooks and a daemon are beyond Arbitype's minimal cross-client service; `gate` here is a pure result transformation, not an interception hook |
49
+ | [blakestone-x/jev-mcp](https://github.com/blakestone-x/jev-mcp) | Typed tools, recipes, request budgets, registration scripts, security notes | Its current test run in this environment had 45 failures caused by an SDK/API boundary mismatch; Arbitype validates its own HTTP response contract independently |
50
+ | [shaharia-lab/jev-cli](https://github.com/shaharia-lab/jev-cli) | Excellent CLI ergonomics, signed installers, CI-oriented exit codes and schemas | Rust was not installed in this environment; Arbitype provides a smaller Python CLI and package entry point |
51
+
52
+ ## Local results
53
+
54
+ - Arbitype: 62 offline tests passed, followed by real Jev requests through
55
+ the MCP STDIO process. The live response returned `jev-1.13.0`, all three
56
+ question types, and token usage; response validation accepted it.
57
+ - `@jkudish/jev-mcp`: build and unit/mock suite passed (the repository's
58
+ live end-to-end test was not run).
59
+ - `burnigtm/jev-mcp`: build and its test runner passed: 141 tests, 139 passed,
60
+ 2 skipped.
61
+ - `jevwire`: build and full Vitest suite passed: 1,461 tests.
62
+ - `blakestone-x/jev-mcp`: packaging completed, but its test suite reported
63
+ 45 failures, 29 passes, and 4 skips in this environment. The failures
64
+ clustered around the installed `typesafe-sdk` response/error boundary and
65
+ stdio fixtures; they are recorded here rather than silently calling it a
66
+ pass.
67
+ - Go and Rust projects could be inspected but not compiled because this host
68
+ does not have `go` or `cargo` installed.
69
+
70
+ ## Host and protocol verification
71
+
72
+ - 62 local unit and integration tests pass with no network access and no API key.
73
+ - A real subprocess STDIO handshake was exercised through `initialize`,
74
+ `notifications/initialized`, `tools/list`, `health`, and `shutdown`.
75
+ - A modern `server/discover` request and per-request `2026-07-28` metadata path
76
+ were exercised, including `resultType`, cache metadata, and unsupported-version
77
+ errors.
78
+ - The official MCP Python SDK v2 connected to the server, negotiated
79
+ `2026-07-28`, listed all 9 tools, and called `health` successfully.
80
+ - The initialization instructions are 484 characters, below the 512-character
81
+ self-contained prefix limit used by the Codex integration.
82
+ - Codex CLI 0.155.1 can list and inspect the configured `arbitype` STDIO server;
83
+ the server advertises only its actual `tools` capability. The wire contract
84
+ itself is host-neutral and uses standard MCP STDIO messages.
85
+ - The wheel was built and installed in an isolated virtual environment, then
86
+ its version, canonical/legacy import identity, and MCP initialization were
87
+ checked.
88
+ - The PEP 517 build path was exercised after removing the source-tree import
89
+ assumption from `setup.py`; clean isolated builds no longer depend on the
90
+ checkout being importable.
91
+ - The default HTTP attempt timeout is 10 seconds, matching the official
92
+ TypeSafe Python SDK and leaving room for bounded retry behavior under common
93
+ MCP host tool timeouts.
94
+ - Live checks remain explicit paid operations; CI continues to use local fakes
95
+ and never receives a provider credential.
96
+
97
+ ## Remaining priorities
98
+
99
+ 1. Add an optional Streamable HTTP deployment package with MCP OAuth discovery;
100
+ keep it separate from the zero-dependency STDIO core.
101
+ 2. Add Inspector/MCPJam-compatible cross-client smoke fixtures and a small
102
+ non-paid evaluation corpus for tool-selection regressions.
103
+ 3. Add structured cancellation and tracing if Jev requests become concurrent or
104
+ long-running; the current synchronous STDIO loop intentionally keeps the
105
+ failure surface small.
106
+
107
+ These are repository smoke-test results, not a quality ranking or a claim that
108
+ one project is safer for every deployment.
109
+
110
+ ## Arbitype design decisions
111
+
112
+ 1. Keep `evaluate` close to TypeSafe's official `POST /v1/systemone` contract.
113
+ 2. Validate before network calls and validate again before returning provider
114
+ data to an agent.
115
+ 3. Prefer bounded, explicit failure over “best effort” approval.
116
+ 4. Keep retry behavior transparent and respect `Retry-After`.
117
+ 5. Never put the API key in MCP arguments, stdout, or normal error details.
118
+ 6. Make the useful convenience tools deterministic wrappers, not hidden agent
119
+ loops or permission systems.
120
+ 7. Keep real-provider tests manual and opt-in; never put a paid live call in CI.
@@ -0,0 +1,111 @@
1
+ # Changelog
2
+
3
+ ## 0.6.0 — 2026-09-22
4
+
5
+ ### Renamed to Arbitype
6
+
7
+ The project formerly known as TypeSafe MCP is now Arbitype. Arbitype is
8
+ positioned as a typed decision layer for AI agents rather than a
9
+ TypeSafe-specific MCP bridge.
10
+
11
+ Canonical identities:
12
+
13
+ - GitHub: `Renwang-Huang/arbitype`
14
+ - PyPI: `arbitype`
15
+ - CLI: `arbitype`
16
+ - Python: `arbitype`
17
+ - MCP Registry: `io.github.Renwang-Huang/arbitype`
18
+
19
+ Legacy names remain available as compatibility aliases where practical. The
20
+ former `typesafe-mcp` PyPI project and Registry identity are not deleted or
21
+ overwritten by this source migration.
22
+
23
+ - Moved the implementation to the canonical `arbitype` package and retained
24
+ module-level identity shims for `typesafe_mcp` and `typesafe_codex_mcp`.
25
+ - Added the `arbitype` CLI and PyPI metadata while retaining both legacy CLI
26
+ aliases.
27
+ - Updated MCP Registry, README, CI, release, and ecosystem-check metadata to
28
+ the Arbitype identity.
29
+ - Verified that a same-name metadata-only `typesafe-mcp` migration wheel can
30
+ leave legacy console scripts stale during pip upgrades; the release keeps
31
+ the old PyPI project untouched and documents the safe uninstall-then-install
32
+ migration instead.
33
+
34
+ ## 0.5.3 — 2026-09-22
35
+
36
+ - Bound STDIO frame reads to 16 MiB and discard oversized lines without
37
+ allocating the complete input; invalid UTF-8 now returns JSON-RPC parse
38
+ error `-32700` without terminating the server.
39
+ - Enforced modern per-request MCP metadata, integer-only JSON-RPC request IDs,
40
+ and invalid explicit `params: null` handling while retaining legacy
41
+ handshake compatibility.
42
+ - Added runtime validation for every advertised tool input and restricted
43
+ custom HTTP API endpoints to loopback hosts; remote endpoints must use
44
+ HTTPS.
45
+ - Added provider-semantic preflight checks for Noul content and non-null Score
46
+ levels, preventing known TypeSafe 400/422 responses after a paid request.
47
+ - Disabled automatic HTTP redirects so bearer credentials are never forwarded
48
+ to a redirect target.
49
+ - Converted deeply nested or otherwise invalid JSON input into JSON-RPC parse
50
+ error `-32700` without terminating the STDIO server.
51
+
52
+ ## 0.5.2 — 2026-09-21
53
+
54
+ - Published the `typesafe-mcp` distribution to PyPI for direct `uvx` installs.
55
+ - Added official MCP Registry metadata and PyPI ownership verification.
56
+
57
+ ## 0.5.1 — 2026-09-21
58
+
59
+ - Made the canonical-versus-legacy package layout explicit in the README and
60
+ compatibility module docstrings; `typesafe_mcp` remains the only
61
+ implementation package.
62
+ - Centralized the package version and strengthened the official SDK smoke test
63
+ so it checks all 9 advertised tools, including `score`.
64
+ - Fixed isolated PEP 517 wheel builds so packaging does not import the source
65
+ package before it has been installed.
66
+
67
+ ## 0.5.0 — 2026-09-21
68
+
69
+ - Added MCP 2026-07-28 STDIO discovery and per-request metadata support while
70
+ retaining the legacy initialize handshake.
71
+ - Added protocol version negotiation errors, modern `resultType` responses, and
72
+ cache metadata for list operations.
73
+ - Replaced generic tool output objects with precise output schemas.
74
+ - Added malformed JSON-RPC/id boundary tests and an official MCP Python SDK v2
75
+ interoperability smoke test in CI.
76
+
77
+ ## 0.4.0 — 2026-09-21
78
+
79
+ - Rebranded the public project as TypeSafe MCP and renamed the distribution and
80
+ primary CLI to `typesafe-mcp`.
81
+ - Added the neutral `typesafe_mcp` import path and retained the old package and
82
+ command as compatibility aliases.
83
+ - Renamed the advertised `route` and `review` tools so the protocol contract is
84
+ not tied to one agent host; the old `codex_route` and `codex_review` calls are
85
+ accepted as migration aliases.
86
+ - Reworked the documentation and host guidance for Codex, Claude, Cursor, VS
87
+ Code, and other MCP-capable clients without adding host-specific runtime code.
88
+
89
+ ## 0.3.0 — 2026-09-21
90
+
91
+ - Narrowed the product contract to a Codex-first stdio MCP service.
92
+ - Added Codex-oriented `codex_route`, `codex_review`, and non-network `health` tools.
93
+ - Added read-only/idempotent MCP tool annotations and a Codex-focused initialization guide.
94
+ - Removed unsupported resource and prompt capabilities and implemented the MCP shutdown/exit lifecycle.
95
+ - Added safer handling for unexpected tool failures.
96
+ - Aligned request/response validation with the official API, including structured null entries,
97
+ required model/usage fields, probability-weighted Score validation, and a 10-second default timeout.
98
+
99
+ ## 0.2.0 — 2026-09-21
100
+
101
+ - Added a reusable standard-library TypeSafe client with bounded retries,
102
+ `Retry-After` support, response validation, request limits, and redacted
103
+ diagnostics.
104
+ - Added `classify`, `score`, `check`, `verify`, and deterministic `gate` MCP
105
+ tools while keeping the raw `evaluate` tool compatible.
106
+ - Added a package entry point, `doctor`, standalone JSON evaluation mode, CI,
107
+ release metadata, and an expanded test suite.
108
+
109
+ ## 0.1.0
110
+
111
+ - Initial dependency-free stdio MCP bridge exposing `evaluate`.
@@ -0,0 +1,28 @@
1
+ # Contributing
2
+
3
+ Small, reviewable pull requests are welcome.
4
+
5
+ Before opening a pull request, run:
6
+
7
+ ```bash
8
+ python3 -m pip install "ruff>=0.8,<1"
9
+ python3 -m ruff check arbitype typesafe_mcp typesafe_codex_mcp server.py smoke_test.py scripts tests
10
+ python3 -m unittest discover -s tests -v
11
+ python3 -m compileall -q .
12
+ python3 -m pip wheel --no-deps . --wheel-dir /tmp/arbitype-dist
13
+ make release-check
14
+ ```
15
+
16
+ `arbitype/` is the canonical implementation package. The `typesafe_mcp/` and
17
+ `typesafe_codex_mcp/` directories are compatibility shims; do not add new
18
+ implementation code there.
19
+
20
+ The old `typesafe-mcp` PyPI project is deliberately not published as a
21
+ same-name migration wheel: pip ownership tests showed that such a wheel can
22
+ leave legacy console scripts stale. Keep the explicit uninstall-then-install
23
+ migration documented in `docs/REGISTRY_MIGRATION.md`.
24
+
25
+ Do not add API keys, live request payloads, or provider responses containing
26
+ private data to fixtures. Prefer local HTTP fakes and deterministic tests. New
27
+ tools should preserve the raw `evaluate` escape hatch, document whether their
28
+ decision is advisory, and fail closed when a provider response is malformed.
arbitype-0.6.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arbitype contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include README.md LICENSE SECURITY.md CHANGELOG.md BENCHMARK.md TESTING.md CONTRIBUTING.md .env.example server.py smoke_test.py
2
+ include server.json
3
+ include scripts/official_sdk_smoke.py
4
+ include scripts/release_readiness.py
5
+ include scripts/validate_registry_metadata.py
6
+ include docs/REGISTRY_MIGRATION.md
7
+ recursive-include arbitype *.py
8
+ recursive-include typesafe_mcp *.py
9
+ recursive-include typesafe_codex_mcp *.py
10
+ recursive-include tests *.py
11
+ global-exclude *.py[cod]
12
+ prune __pycache__
13
+ prune */__pycache__
@@ -0,0 +1,360 @@
1
+ Metadata-Version: 2.4
2
+ Name: arbitype
3
+ Version: 0.6.0
4
+ Summary: Typed decision tools for AI agents, powered by TypeSafe Jev
5
+ Home-page: https://github.com/Renwang-Huang/arbitype
6
+ Author: Arbitype contributors
7
+ Author-email: renwang-huang@users.noreply.github.com
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/Renwang-Huang/arbitype
10
+ Project-URL: Repository, https://github.com/Renwang-Huang/arbitype
11
+ Project-URL: Issues, https://github.com/Renwang-Huang/arbitype/issues
12
+ Project-URL: Changelog, https://github.com/Renwang-Huang/arbitype/blob/main/CHANGELOG.md
13
+ Keywords: arbitype,mcp,model-context-protocol,ai-agents,agent,decision,typed-decisions,classification,routing,verification,guardrails,jev,typesafe-ai,python
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Dynamic: author-email
27
+ Dynamic: home-page
28
+ Dynamic: license-file
29
+ Dynamic: requires-python
30
+
31
+ <div align="center">
32
+
33
+ # Arbitype
34
+
35
+ <p><strong>Typed decision tools for AI agents.</strong></p>
36
+
37
+ <p>Classify · Score · Verify · Gate · Route · Review</p>
38
+
39
+ <p><strong>MCP-native · Powered by TypeSafe Jev</strong></p>
40
+
41
+ <p>
42
+ <a href="https://github.com/Renwang-Huang/arbitype/actions/workflows/ci.yml"><img src="https://github.com/Renwang-Huang/arbitype/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
43
+ <a href="https://github.com/Renwang-Huang/arbitype/releases"><img src="https://img.shields.io/github/v/release/Renwang-Huang/arbitype?display_name=tag&sort=semver" alt="Latest release"></a>
44
+ <a href="https://pypi.org/project/arbitype/"><img src="https://img.shields.io/badge/PyPI-0.6.0%20pending-lightgrey" alt="Arbitype PyPI publication pending"></a>
45
+ <a href="https://github.com/Renwang-Huang/arbitype/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Renwang-Huang/arbitype" alt="MIT license"></a>
46
+ <img src="https://img.shields.io/badge/python-3.10%2B-3776AB?logo=python&logoColor=white" alt="Python 3.10 or newer">
47
+ <a href="https://github.com/modelcontextprotocol/modelcontextprotocol/tree/main/docs/specification/2026-07-28"><img src="https://img.shields.io/badge/MCP-2026--07--28-6F42C1" alt="MCP 2026-07-28"></a>
48
+ </p>
49
+
50
+ <p>
51
+ <a href="https://registry.modelcontextprotocol.io/?q=io.github.Renwang-Huang%2Farbitype"><img src="https://img.shields.io/badge/MCP%20Registry-0.6.0%20pending-lightgrey" alt="Arbitype MCP Registry publication pending"></a>
52
+ <a href="https://glama.ai/mcp/servers/Renwang-Huang/arbitype"><img src="https://img.shields.io/badge/Glama-crawl%20pending-lightgrey" alt="Arbitype Glama crawl pending"></a>
53
+ </p>
54
+
55
+ <p>
56
+ <a href="#quick-start">Quick start</a> ·
57
+ <a href="#why-arbitype">Why Arbitype?</a> ·
58
+ <a href="#tools">Tools</a> ·
59
+ <a href="#host-setup">Host setup</a> ·
60
+ <a href="#configuration">Configuration</a> ·
61
+ <a href="BENCHMARK.md">Engineering benchmark</a>
62
+ </p>
63
+
64
+ </div>
65
+
66
+ Arbitype is an MCP-native typed decision layer for AI agents, powered by
67
+ [TypeSafe Jev](https://typesafe.ai). It turns probabilistic judgments into
68
+ structured decision primitives that an agent or program can consume directly.
69
+
70
+ > [!NOTE]
71
+ > Arbitype is an independent open-source project. It is not an official
72
+ > TypeSafe AI product or an official integration for any particular agent host.
73
+
74
+ <!-- mcp-name: io.github.Renwang-Huang/arbitype -->
75
+
76
+ ## Quick start
77
+
78
+ The shortest path is a local STDIO server launched by `uvx`:
79
+
80
+ ```bash
81
+ export TYPESAFE_API_KEY="your-key"
82
+ uvx arbitype
83
+ ```
84
+
85
+ The API key stays in the process environment. It is not an MCP argument and
86
+ is never printed to standard output.
87
+
88
+ Install a pinned release with:
89
+
90
+ ```bash
91
+ uvx --from 'arbitype==0.6.0' arbitype
92
+ ```
93
+
94
+ Or run the repository checkout:
95
+
96
+ ```bash
97
+ git clone https://github.com/Renwang-Huang/arbitype.git
98
+ cd arbitype
99
+ export TYPESAFE_API_KEY="your-key"
100
+ python3 server.py
101
+ ```
102
+
103
+ ## Why Arbitype?
104
+
105
+ Generative models are excellent at prose, code, and open-ended generation.
106
+ Agent workflows also need bounded decisions that software can branch on:
107
+
108
+ ```text
109
+ free-form state
110
+
111
+ TypeSafe Jev
112
+
113
+ probabilistic judgment
114
+
115
+ Arbitype
116
+
117
+ typed decision + probability
118
+
119
+ agent / code branch
120
+ ```
121
+
122
+ Arbitype provides that decision layer over MCP. It exposes short, host-neutral
123
+ primitives for classification, scoring, verification, routing, review, and
124
+ fail-closed gate signals. The result is structured data, not a paragraph that
125
+ an agent must interpret again.
126
+
127
+ ## Architecture
128
+
129
+ ```mermaid
130
+ flowchart LR
131
+ host["AI Agent / MCP Host<br/>Codex · Claude · Cursor · VS Code"]
132
+ arbitype["Arbitype<br/>Typed decision tools"]
133
+ jev["TypeSafe Jev<br/>System One Model"]
134
+ env["TYPESAFE_API_KEY<br/>process environment"]
135
+
136
+ host -->|MCP| arbitype
137
+ arbitype -->|validated HTTPS| jev
138
+ jev -->|typed probabilistic judgment| arbitype
139
+ arbitype -->|structured decision| host
140
+ env -. credential .-> arbitype
141
+ ```
142
+
143
+ The public product is Arbitype; TypeSafe Jev is the current provider. Provider
144
+ configuration intentionally keeps the `TYPESAFE_*` names because the
145
+ credential and endpoint belong to TypeSafe.
146
+
147
+ ## Tools
148
+
149
+ Arbitype advertises nine read-only, idempotent MCP tools:
150
+
151
+ | Tool | Input shape | Output |
152
+ | --- | --- | --- |
153
+ | `evaluate` | `state` + TypeSafe `questions` map | Raw typed Jev response |
154
+ | `classify` | `state` + `instructions` + `labels` | Choice and probability distribution |
155
+ | `score` | `state` + `instructions` + ordered `levels` | Weighted score and distribution |
156
+ | `check` | `state` + yes/no criteria | Noul probability |
157
+ | `verify` | `state` + `claims` map | Noul answer per claim |
158
+ | `gate` | `state` + `checks` + thresholds | `pass`, `review`, or `fail` signal |
159
+ | `route` | `state` + `actions` map | One suggested next action; no execution |
160
+ | `review` | `state` + `checks` + thresholds | Review decision and evidence |
161
+ | `health` | Optional `live` boolean | Local configuration; live request only when explicit |
162
+
163
+ For raw Noul questions, provide non-empty `instructions` or at least one
164
+ non-empty `true`/`false` criterion. Score levels must be non-null structured
165
+ values. These provider-level constraints are validated locally before a paid
166
+ request.
167
+
168
+ Probabilities and confidence are model signals, not proof. `gate` and `review`
169
+ are advisory decision transformations, not authorization systems, security
170
+ boundaries, or approval engines.
171
+
172
+ ## Host setup
173
+
174
+ Arbitype uses standard MCP STDIO. For a host that accepts an installed command:
175
+
176
+ ```toml
177
+ [mcp_servers.arbitype]
178
+ command = "arbitype"
179
+ env_vars = ["TYPESAFE_API_KEY"]
180
+ startup_timeout_sec = 10
181
+ tool_timeout_sec = 60
182
+ default_tools_approval_mode = "prompt"
183
+ ```
184
+
185
+ For a checkout:
186
+
187
+ ```toml
188
+ [mcp_servers.arbitype]
189
+ command = "python3"
190
+ args = ["/absolute/path/to/arbitype/server.py"]
191
+ env_vars = ["TYPESAFE_API_KEY"]
192
+ startup_timeout_sec = 10
193
+ tool_timeout_sec = 60
194
+ ```
195
+
196
+ The same process can be registered by Claude, Cursor, VS Code, Codex, or any
197
+ other MCP host using its native configuration format. Keep the key out of host
198
+ configuration files; use the host's environment forwarding mechanism.
199
+
200
+ ## CLI and Python
201
+
202
+ The canonical CLI and package are `arbitype`:
203
+
204
+ ```bash
205
+ arbitype --version
206
+ arbitype doctor --json
207
+ cat request.json | arbitype evaluate
208
+ arbitype evaluate --input request.json
209
+ ```
210
+
211
+ The Python API is intentionally small:
212
+
213
+ ```python
214
+ from arbitype import TypeSafeClient
215
+
216
+ client = TypeSafeClient()
217
+ result = client.evaluate({
218
+ "state": "A payment failed twice.",
219
+ "questions": {
220
+ "urgent": {
221
+ "type": "noul",
222
+ "instructions": "Does this require urgent handling?",
223
+ }
224
+ },
225
+ })
226
+ ```
227
+
228
+ ### Package and import compatibility
229
+
230
+ The canonical wheel contains the one implementation plus the legacy import
231
+ shims. The old PyPI project is not deleted, yanked, or released under a new
232
+ identity.
233
+
234
+ | Surface | Name | Status |
235
+ | --- | --- | --- |
236
+ | PyPI | `arbitype` | Canonical distribution |
237
+ | Python | `arbitype` | Canonical import |
238
+ | Python | `typesafe_mcp` | Legacy compatibility shim |
239
+ | Python | `typesafe_codex_mcp` | Legacy compatibility shim |
240
+
241
+ ### CLI compatibility
242
+
243
+ | Command | Status |
244
+ | --- | --- |
245
+ | `arbitype` | Canonical CLI |
246
+ | `typesafe-mcp` | Legacy CLI alias |
247
+ | `typesafe-codex-mcp` | Legacy CLI alias |
248
+
249
+ ### Tool compatibility
250
+
251
+ | Tool | Status |
252
+ | --- | --- |
253
+ | `route` | Canonical |
254
+ | `review` | Canonical |
255
+ | `codex_route` | Legacy alias |
256
+ | `codex_review` | Legacy alias |
257
+
258
+ The historical `typesafe-mcp` PyPI project remains intact. A metadata-only
259
+ replacement with the same distribution name was tested and rejected because
260
+ pip can remove legacy console-script files while replacing the old
261
+ distribution. Therefore no `typesafe-mcp==0.6.0` migration package will be
262
+ published.
263
+
264
+ Existing users should use this explicit, safe migration:
265
+
266
+ ```bash
267
+ python -m pip uninstall typesafe-mcp
268
+ python -m pip install arbitype
269
+ ```
270
+
271
+ New installations should use `arbitype` directly. This leaves one
272
+ distribution owning the canonical implementation, compatibility shims, and
273
+ all three CLI entry points.
274
+
275
+ ## Discovery and Registry
276
+
277
+ The canonical MCP Registry identity is:
278
+
279
+ ```text
280
+ io.github.Renwang-Huang/arbitype
281
+ ```
282
+
283
+ The intended package entry is:
284
+
285
+ ```text
286
+ uvx arbitype
287
+ ```
288
+
289
+ The PyPI, MCP Registry, and Glama links are prepared before publication, but
290
+ their badges remain explicitly marked pending until the external listings are
291
+ verified. Release ordering and the legacy Registry migration procedure are
292
+ documented in [docs/REGISTRY_MIGRATION.md](docs/REGISTRY_MIGRATION.md).
293
+
294
+ The former identity `io.github.Renwang-Huang/typesafe-mcp` is a legacy
295
+ identity. It must remain available for existing users and should be marked
296
+ deprecated through the Registry publisher when that mutation is supported.
297
+ New installations should use the Arbitype identity.
298
+
299
+ ## Configuration
300
+
301
+ | Variable | Default | Purpose |
302
+ | --- | --- | --- |
303
+ | `TYPESAFE_API_KEY` | — | Required TypeSafe bearer credential |
304
+ | `TYPESAFE_BASE_URL` | `https://api.typesafe.ai` | API base URL |
305
+ | `TYPESAFE_MODEL` | `jev-latest` | Model alias; legacy name supported |
306
+ | `TYPESAFE_DEFAULT_MODEL` | `jev-latest` | Official SDK-compatible model name |
307
+ | `TYPESAFE_TIMEOUT_SECONDS` | `10` | Per HTTP attempt timeout |
308
+ | `TYPESAFE_MAX_RETRIES` | `2` | Retries after the initial request |
309
+ | `TYPESAFE_RETRY_BACKOFF_SECONDS` | `0.5` | Initial exponential backoff |
310
+ | `TYPESAFE_MAX_STATE_CHARS` | `120000` | Serialized state limit |
311
+ | `TYPESAFE_MAX_QUESTION_CHARS` | `60000` | Serialized question limit |
312
+ | `TYPESAFE_MAX_REQUEST_BYTES` | `512000` | Whole request limit |
313
+ | `TYPESAFE_MAX_RESPONSE_BYTES` | `4194304` | Provider response limit |
314
+
315
+ Custom provider endpoints must use HTTPS. Plain HTTP is accepted only for
316
+ loopback hosts such as `localhost`, `127.0.0.1`, and `::1`. Redirects are
317
+ disabled so a bearer credential is never forwarded to a redirect target.
318
+
319
+ ## Security boundaries
320
+
321
+ Arbitype is a local MCP adapter and typed decision layer. It is not:
322
+
323
+ - a sandbox for untrusted code;
324
+ - an authorization or identity system;
325
+ - a prompt-injection firewall;
326
+ - a security approval boundary; or
327
+ - an official TypeSafe AI product.
328
+
329
+ It does not execute actions suggested by `route`, edit files, run shell
330
+ commands, or treat model probabilities as proof. Read [SECURITY.md](SECURITY.md)
331
+ before using live credentials.
332
+
333
+ ## Development
334
+
335
+ ```bash
336
+ python3 -m unittest discover -s tests -v
337
+ python3 -m compileall -q .
338
+ python3 -m pip wheel --no-deps . --wheel-dir /tmp/arbitype-dist
339
+ ```
340
+
341
+ The test suite uses local fakes and does not need an API key. The official MCP
342
+ Python SDK interoperability smoke test is in
343
+ [`scripts/official_sdk_smoke.py`](scripts/official_sdk_smoke.py). A live Jev
344
+ check is opt-in and paid:
345
+
346
+ ```bash
347
+ TYPESAFE_API_KEY="your-key" arbitype doctor --live
348
+ ```
349
+
350
+ See [TESTING.md](TESTING.md), [CONTRIBUTING.md](CONTRIBUTING.md), and
351
+ [BENCHMARK.md](BENCHMARK.md) for the full engineering checks and comparison.
352
+ Maintainer migration details are in
353
+ [`docs/REGISTRY_MIGRATION.md`](docs/REGISTRY_MIGRATION.md).
354
+
355
+ ## Release identity
356
+
357
+ Arbitype is currently released as `0.6.0` because it remains Beta while its
358
+ canonical public identity moves to the new package, CLI, and Registry name.
359
+ The old package history remains intact; the brand migration does not rewrite
360
+ Git history or delete the former PyPI project.