Skip to content

feat: add caller-controlled MCP methods - #95

Open
HareeshBahuleyan wants to merge 3 commits into
mainfrom
feat/65-public-mcp
Open

HareeshBahuleyan wants to merge 3 commits into
mainfrom
feat/65-public-mcp

Conversation

@HareeshBahuleyan

@HareeshBahuleyan HareeshBahuleyan commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Applications need supported SDK methods to discover MCP tools and execute the exact caller-authorized call through Otari, without losing approval boundaries or indeterminate outcomes.

The auto-generated PR updates only src/otari/_client/; this separate PR exposes those endpoints through the hand-written public SDK and adds the single-attempt execution guarantees and typed error handling that code generation does not provide.

What changed

Add sync/async mcp.list_tools(...) and mcp.execute(...) on /api/v1, public generated types, required server_revision, and MCP errors preserving code, execution_state, and request_id. Execution bypasses urllib3 retries, never follows redirects, and treats untyped transport failures as outcome-unknown. Tests count attempts beneath HTTPX's connection retry loop, including environment proxies. No generated code, Files changes, or Octonous integration is included.

Notes

  • Tests: UV_FROZEN=true uv run pytest: 319 passed, 7 integration tests skipped (no gateway), including 180 mocked MCP cases. The same counts passed with uv run --isolated --python 3.11 --extra dev pytest -q and --python 3.13; default Python was 3.12.8. Both isolated runs also used UV_FROZEN=true. No real MCP tools ran.
  • Checks: UV_FROZEN=true uv run ruff check . passed; UV_FROZEN=true uv run mypy src/ passed (10 files); UV_FROZEN=true uv run pytest tests/unit/test_endpoint_coverage.py -v passed (3 tests). uv build, uvx twine check dist/otari-0.4.0.tar.gz dist/otari-0.4.0-py3-none-any.whl, isolated installed-wheel smoke checks (public exports, typing marker, sync/async resources and close), and git diff --check passed.
  • Gateway follow-up: move GET /api/v1/mcp/servers/{mcp_server_id}/tools and POST /api/v1/mcp/execute from excluded to covered in mozilla-ai/otari/scripts/sdk_codegen/sdk-endpoints.txt, then regenerate the SDK copy. That generated file is intentionally untouched here. A new SDK release is needed after merge; no release was published.
  • Existing lockfile mismatch: main's uv.lock records the root package as 0.2.0 while pyproject.toml is 0.4.0. Final runs used UV_FROZEN=true to avoid an unrelated lockfile edit. No SDK implementation blockers remain; gateway deployment was not verified.
  • AI disclosure: implemented and checked with Pi using gpt-6-astra.

Fixes #65

Expose sync and async stored-server discovery and execution with public generated types, required server revisions, and MCP-specific typed errors.

Use HTTPX's zero-retry transport instead of the generated urllib3 retry path. Preserve indeterminate outcomes and disable redirects; test request counts beneath the connection retry loop.

Document approval boundaries, correlation-only execution IDs, cancellation, and the separate gateway endpoint-manifest follow-up.

Fixes #65
@HareeshBahuleyan HareeshBahuleyan self-assigned this Sep 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Typed errors currently rewrite the valid completed execution state to not_started, potentially misleading callers about retry safety.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds public synchronous and asynchronous caller-controlled MCP operations with single-attempt execution safeguards.

Changes:

  • Adds MCP tool discovery and execution resources.
  • Adds typed MCP errors and generated model exports.
  • Adds extensive transport, authentication, and response tests.
File Description
src/​otari/​mcp.py Implements sync and async MCP operations.
src/​otari/​client.py Exposes the synchronous MCP resource.
src/​otari/​async_client.py Exposes the asynchronous MCP resource.
src/​otari/​errors.py Adds MCP-specific exceptions.
src/​otari/​types.py Re-exports generated MCP models.
src/​otari/​__init__.py Publishes MCP types and errors.
tests/​unit/​test_mcp.py Tests MCP contracts and single-attempt behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/otari/mcp.py Outdated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add caller-orchestrated MCP methods

2 participants