feat: add Superposition MCP server implementation#921
Draft
feat: add Superposition MCP server implementation#921
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3a3a7bb to
82db1ac
Compare
Outlines architecture for a new superposition_mcp crate that exposes all Smithy-defined API operations as MCP tools using rmcp and the superposition_sdk client. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
Implements a Model Context Protocol (MCP) server as a new workspace crate that exposes all Superposition API operations as MCP tools. Architecture: - Uses rmcp 1.2.0 (official Rust MCP SDK) with #[tool_router] macros - Delegates all API calls to superposition_sdk client - workspace_id and org_id configured once via env vars - Supports stdio transport for Claude Desktop, Cursor, etc. Tools (70+ covering all Smithy operations): - config.* — Config retrieval, resolution, versions - default_config.* — Default config CRUD - dimension.* — Dimension CRUD - context.* — Context CRUD, move, bulk ops, weight recompute - experiment.* — Experiment lifecycle (create, ramp, pause, conclude) - experiment_group.* — Experiment group management - function.* — Custom function CRUD, test, publish - type_template.* — Type template CRUD - organisation.* — Organisation CRUD - workspace.* — Workspace CRUD - audit_log.list — Audit log queries - variable.* — Variable CRUD - webhook.* — Webhook CRUD - secret.* — Secret CRUD Includes 21 tests covering config, helpers, server construction, and tool capability registration. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
…tifier Implements the two remaining non-admin Smithy operations that were missing from the MCP server, both using the corresponding SDK client functions. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
Mounts the MCP server at /{base}/mcp using Streamable HTTP transport
via rmcp-actix-web. Gated behind:
- Cargo feature: `mcp` (on superposition crate)
- Env var: `SUPERPOSITION_MCP=true` (runtime toggle)
https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
- Fix 85 redundant closure warnings (|e| mcp_err(e) → mcp_err) - Move tools/mod.rs to tools.rs to satisfy mod_module_files lint - Fix approx_constant clippy error in test (3.14 → 2.72) - Apply cargo fmt formatting fixes https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
The Nix CI build needs native dependency configuration (openssl, postgresql) for the new superposition_mcp crate, matching the pattern used by other crates in the workspace. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
9f603b8 to
16416bb
Compare
16416bb to
439e9ed
Compare
The uniffi bindings check passes locally with Rust 1.90.0 and the same toolchain as CI. Retriggering to verify. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
Documents a plan to auto-generate MCP tool code from Smithy models, eliminating ~3000 lines of boilerplate. Covers mapping rules, two implementation approaches (Smithy plugin vs standalone Rust generator), and integration steps. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
Implements a Smithy build plugin (Java) that reads .smithy models and generates Rust MCP tool code deterministically. When a new Smithy operation or resource is added, the MCP tool code is auto-generated with zero manual work. The plugin generates: - Parameter structs with Deserialize + JsonSchema derives - Tool implementation methods with SDK builder calls - Tool registration (#[tool_router] impl block) - Response formatting macros Files: - smithy/mcp-codegen/ — Java plugin source (Gradle build) - crates/superposition_mcp/src/generated/ — generated Rust output - smithy-build.json — plugin registered as mcp-rust-codegen - makefile — mcp-codegen-build and mcp-codegen-run targets The generated code lives alongside the existing hand-written tools. To fully integrate, replace the hand-written tool files with the generated equivalents and update lib.rs to use the generated module. https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Superposition API operations need to be exposed through the Model Context Protocol (MCP) to enable AI assistants and other MCP clients to interact with Superposition's configuration management, experimentation, and workspace features.
Solution
Implemented a complete MCP server for Superposition that exposes all major API operations as MCP tools. The implementation includes:
Core Server (
server.rs): MainSuperpositionMcpServerstruct with 50+ MCP tools covering:Tool Modules: Organized parameter types and implementation functions for each domain:
config.rs,context.rs,dimension.rs,default_config.rsexperiment.rs,experiment_group.rs,function.rsorganisation.rs,workspace.rs,webhook.rs,secret.rs,variable.rs,type_template.rs,audit_log.rsHelper Functions (
helpers.rs): Utility functions for:serde_json::Valueandaws_smithy_types::DocumentConfiguration (
config.rs):McpServerConfigstruct that reads from environment variables and builds the SDK clientTests: Unit tests for helper functions and server construction
Environment variable changes
The MCP server reads the following environment variables:
SUPERPOSITION_URL(required): Base URL of the Superposition APISUPERPOSITION_WORKSPACE_ID(required): Default workspace IDSUPERPOSITION_ORG_ID(required): Default organisation IDSUPERPOSITION_AUTH_TOKEN(optional): Bearer token for authenticationPre-deployment activity
None
Post-deployment activity
None
API changes
No new API endpoints. This change exposes existing Superposition API operations through the MCP protocol.
Possible Issues in the future
https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr