{
  "mcpVersion": "2025-03-26",
  "name": "contextshim",
  "title": "ContextShim Wire Rule & Simulation MCP Server",
  "description": "Manage CAS-fenced LLM wire interception rules, simulate wire payload diffs, inspect SHA-256 wire traces, and mint developer keys.",
  "homepage": "https://contextshim.com",
  "transport": {
    "type": "streamable-http",
    "url": "https://contextshim.com/mcp"
  },
  "tools": [
    {
      "name": "contextshim_list_rules",
      "description": "List active or all deterministic wire interception rules in ContextShim ordered by priority.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "respond_directly",
              "inject_context",
              "passthrough_audit"
            ],
            "description": "Optional filter by execution mode."
          },
          "enabled_only": {
            "type": "boolean",
            "description": "When true, return only enabled rules."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "contextshim_upsert_rule",
      "description": "Create or update a ContextShim wire rule with compare-and-swap (CAS) expected_version concurrency protection.",
      "inputSchema": {
        "type": "object",
        "required": [
          "name",
          "mode"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable slug rule ID (e.g. rule-team-typescript)."
          },
          "name": {
            "type": "string",
            "description": "Human-readable rule title."
          },
          "description": {
            "type": "string",
            "description": "Explanation of what this rule intercepts or injects."
          },
          "mode": {
            "type": "string",
            "enum": [
              "respond_directly",
              "inject_context",
              "passthrough_audit"
            ]
          },
          "priority": {
            "type": "integer",
            "description": "Evaluation priority (-1000 to 1000; higher runs first)."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the rule is active."
          },
          "expected_version": {
            "type": "integer",
            "description": "CAS expected version (0 or omit for new rules; current live version required for updates)."
          },
          "predicates": {
            "type": "object",
            "description": "Matching predicates: regex, keyword_any, model_glob, header_match, path, role_scope, project_tag."
          },
          "action": {
            "type": "object",
            "description": "Action config: response_template (for respond_directly) or system_prepend, system_append, user_prepend, user_append (for inject_context)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "contextshim_simulate",
      "description": "Simulate or run a live ContextShim wire call across OpenAI Chat, Anthropic Messages, OpenAI Responses, or Cloud Ollama, returning wire diffs and receipt headers.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "protocol": {
            "type": "string",
            "enum": [
              "openai",
              "anthropic",
              "responses",
              "ollama"
            ],
            "description": "Target wire protocol format."
          },
          "prompt": {
            "type": "string",
            "description": "User message prompt when payload is omitted."
          },
          "model": {
            "type": "string",
            "description": "Model identifier (e.g. glm-5.3-flash, claude-sonnet-4-5, gpt-4.1)."
          },
          "live": {
            "type": "boolean",
            "description": "When true, forward inject_context or passthrough_audit calls to Cloud Ollama (https://ollama.com/v1) and record a live trace."
          },
          "payload": {
            "type": "object",
            "description": "Optional raw wire JSON payload."
          },
          "headers": {
            "type": "object",
            "description": "Optional HTTP header dictionary for header_match or project_tag testing."
          },
          "rule_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Optional subset of rule IDs to evaluate."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "contextshim_list_traces",
      "description": "Fetch recent intercepted LLM wire traces with mode, matched rules, latency, token savings, and SHA-256 request/response digests.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Maximum traces to return (default 20)."
          },
          "mode": {
            "type": "string",
            "enum": [
              "respond_directly",
              "inject_context",
              "passthrough_audit"
            ],
            "description": "Optional filter by execution mode."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "contextshim_mint_key",
      "description": "Mint a self-serve ContextShim developer API key (cshim_live_*) for Free Developer, Pro, or Team sandboxes.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "Descriptive label for the API key."
          },
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "pro",
              "team"
            ],
            "description": "Plan tier (defaults to free)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "contextshim_get_insights",
      "description": "Inspect Top-of-Mind project entities, learned user-correction candidate rules, and empirical rule acceptance vs. pain telemetry.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "project_tag": {
            "type": "string",
            "description": "Optional project tag filter."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "description": "Max items per section (default 20)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "contextshim_promote_candidate",
      "description": "Promote or dismiss a self-discovered behavioral candidate rule into a live CAS-fenced ContextShim rule.",
      "inputSchema": {
        "type": "object",
        "required": [
          "candidate_id"
        ],
        "properties": {
          "candidate_id": {
            "type": "string",
            "description": "Candidate rule identifier (cand_...)."
          },
          "action": {
            "type": "string",
            "enum": [
              "promote",
              "dismiss"
            ],
            "description": "Decision (default promote)."
          },
          "priority": {
            "type": "integer",
            "description": "Optional rule priority on promotion (default 72)."
          }
        },
        "additionalProperties": false
      }
    }
  ]
}