Skip to content

feat: add Superposition MCP server implementation#921

Draft
knutties wants to merge 11 commits intomainfrom
claude/superposition-mcp-server-LkDj9
Draft

feat: add Superposition MCP server implementation#921
knutties wants to merge 11 commits intomainfrom
claude/superposition-mcp-server-LkDj9

Conversation

@knutties
Copy link
Copy Markdown
Collaborator

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): Main SuperpositionMcpServer struct with 50+ MCP tools covering:

    • Configuration management (get, resolve, versioning)
    • Default configs (CRUD operations)
    • Dimensions (CRUD operations)
    • Contexts (CRUD, move, override management)
    • Experiments and experiment groups
    • Functions, secrets, variables, type templates
    • Webhooks, audit logs
    • Organisation and workspace management
  • Tool Modules: Organized parameter types and implementation functions for each domain:

    • config.rs, context.rs, dimension.rs, default_config.rs
    • experiment.rs, experiment_group.rs, function.rs
    • organisation.rs, workspace.rs, webhook.rs, secret.rs, variable.rs, type_template.rs, audit_log.rs
  • Helper Functions (helpers.rs): Utility functions for:

    • Converting between serde_json::Value and aws_smithy_types::Document
    • Formatting datetime values
    • Creating MCP error responses
    • Macros for serializing domain objects to JSON
  • Configuration (config.rs): McpServerConfig struct that reads from environment variables and builds the SDK client

  • Tests: 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 API
  • SUPERPOSITION_WORKSPACE_ID (required): Default workspace ID
  • SUPERPOSITION_ORG_ID (required): Default organisation ID
  • SUPERPOSITION_AUTH_TOKEN (optional): Bearer token for authentication

Pre-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

  • MCP tool parameter validation relies on JSON schema definitions; ensure parameter types remain consistent with SDK expectations
  • Error handling converts SDK errors to MCP error format; monitor error message clarity for debugging
  • The server uses a single SDK client instance; consider connection pooling if scaling to high concurrency

https://claude.ai/code/session_019JAVXMR5P5oxrBq8fazjnr

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 19, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  crates/frontend/src/components/default_config_form.rs  63% smaller
  smithy/smithy-build.json  50% smaller
  .gitignore Unsupported file format
  Cargo.lock Unsupported file format
  Cargo.toml Unsupported file format
  crates/superposition/Cargo.toml Unsupported file format
  crates/superposition/src/main.rs  0% smaller
  crates/superposition_mcp/CODEGEN_PLAN.md Unsupported file format
  crates/superposition_mcp/Cargo.toml Unsupported file format
  crates/superposition_mcp/src/actix.rs  0% smaller
  crates/superposition_mcp/src/config.rs  0% smaller
  crates/superposition_mcp/src/generated/audit_log.rs  0% smaller
  crates/superposition_mcp/src/generated/config.rs  0% smaller
  crates/superposition_mcp/src/generated/config_version.rs  0% smaller
  crates/superposition_mcp/src/generated/context.rs  0% smaller
  crates/superposition_mcp/src/generated/default_config.rs  0% smaller
  crates/superposition_mcp/src/generated/dimension.rs  0% smaller
  crates/superposition_mcp/src/generated/experiment_group.rs  0% smaller
  crates/superposition_mcp/src/generated/experiments.rs  0% smaller
  crates/superposition_mcp/src/generated/function.rs  0% smaller
  crates/superposition_mcp/src/generated/master_key.rs  0% smaller
  crates/superposition_mcp/src/generated/mod.rs  0% smaller
  crates/superposition_mcp/src/generated/organisation.rs  0% smaller
  crates/superposition_mcp/src/generated/response_macros.rs  0% smaller
  crates/superposition_mcp/src/generated/secret.rs  0% smaller
  crates/superposition_mcp/src/generated/server_tools.rs  0% smaller
  crates/superposition_mcp/src/generated/type_templates.rs  0% smaller
  crates/superposition_mcp/src/generated/variable.rs  0% smaller
  crates/superposition_mcp/src/generated/webhook.rs  0% smaller
  crates/superposition_mcp/src/generated/workspace.rs  0% smaller
  crates/superposition_mcp/src/helpers.rs  0% smaller
  crates/superposition_mcp/src/lib.rs  0% smaller
  crates/superposition_mcp/src/main.rs  0% smaller
  crates/superposition_mcp/src/server.rs  0% smaller
  crates/superposition_mcp/src/tools.rs  0% smaller
  crates/superposition_mcp/src/tools/audit_log.rs  0% smaller
  crates/superposition_mcp/src/tools/config.rs  0% smaller
  crates/superposition_mcp/src/tools/context.rs  0% smaller
  crates/superposition_mcp/src/tools/default_config.rs  0% smaller
  crates/superposition_mcp/src/tools/dimension.rs  0% smaller
  crates/superposition_mcp/src/tools/experiment.rs  0% smaller
  crates/superposition_mcp/src/tools/experiment_group.rs  0% smaller
  crates/superposition_mcp/src/tools/function.rs  0% smaller
  crates/superposition_mcp/src/tools/organisation.rs  0% smaller
  crates/superposition_mcp/src/tools/secret.rs  0% smaller
  crates/superposition_mcp/src/tools/type_template.rs  0% smaller
  crates/superposition_mcp/src/tools/variable.rs  0% smaller
  crates/superposition_mcp/src/tools/webhook.rs  0% smaller
  crates/superposition_mcp/src/tools/workspace.rs  0% smaller
  crates/superposition_mcp/tests/helpers_tests.rs  0% smaller
  crates/superposition_mcp/tests/server_tests.rs  0% smaller
  makefile Unsupported file format
  nix/rust.nix Unsupported file format
  smithy/mcp-codegen/build.gradle.kts Unsupported file format
  smithy/mcp-codegen/pom.xml  0% smaller
  smithy/mcp-codegen/settings.gradle.kts Unsupported file format
  smithy/mcp-codegen/src/main/java/io/superposition/mcp/codegen/McpCodegenPlugin.java  0% smaller
  smithy/mcp-codegen/src/main/java/io/superposition/mcp/codegen/McpCodegenRunner.java  0% smaller
  smithy/mcp-codegen/src/main/java/io/superposition/mcp/codegen/McpRustGenerator.java  0% smaller
  smithy/mcp-codegen/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin Unsupported file format

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c95a003c-d680-4ab3-bace-4d539e82fac5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/superposition-mcp-server-LkDj9

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@knutties knutties force-pushed the claude/superposition-mcp-server-LkDj9 branch from 3a3a7bb to 82db1ac Compare March 19, 2026 14:11
@knutties knutties changed the title Add Superposition MCP server implementation feat: add Superposition MCP server implementation Mar 19, 2026
claude added 7 commits March 21, 2026 17:17
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
@knutties knutties force-pushed the claude/superposition-mcp-server-LkDj9 branch from 9f603b8 to 16416bb Compare March 21, 2026 11:47
@knutties knutties force-pushed the claude/superposition-mcp-server-LkDj9 branch from 16416bb to 439e9ed Compare March 21, 2026 11:48
claude added 3 commits March 21, 2026 13:55
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
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.

2 participants