Skip to main content
Glama

switch-trust-mcp

A local MCP server (stdio) that gives a coding agent read-only access to a Switch Trust backend's AI-SPM issues, inventory, guardrails, cost optimization and remediation guidance so it can fix the flagged code.

It is a thin, authenticated REST client over the Switch Trust API — no scanner runs locally and no backend changes are required. Everything valuable (AI-reasoned findings, rule-based issues, public-asset vuln enrichment, remediation guidance) is already computed server-side and served over the existing API / static assets.

Install & run

The idiomatic way is via the published wheel with uvx (no clone, no build step):

uvx switch-trust-mcp

Related MCP server: AgentLens MCP Server

Configuration

Set two environment variables:

Variable

Meaning

SWITCH_TRUST_API_KEY

Switch Trust API key (sk_...).

SWITCH_TRUST_INSTANCE

Switch Trust instance base URL, e.g. https://app.switchagents.ai.

The instance URL is validated against a fail-closed host allowlist before any credential is attached, and must be a bare origin (no path, query or credentials). Set it to the web app URL: API calls go to the same deployment's api. host automatically (https://app.switchagents.ai → https://api.switchagents.ai).

The tenant and workspace are auto-discovered from the API key at startup — you do not configure any IDs. A key is pinned to exactly one tenant + active workspace by the backend.

The API key is only ever sent in the Authorization: ApiKey ... header and is never logged.

Wiring into a coding agent

Add to your MCP client config (Claude Code .mcp.json, Cursor, etc.):

{
  "mcpServers": {
    "switch-trust-mcp": {
      "command": "uvx",
      "args": ["switch-trust-mcp"],
      "env": {
        "SWITCH_TRUST_API_KEY": "sk_...",
        "SWITCH_TRUST_INSTANCE": "https://app.switchagents.ai"
      }
    }
  }
}

Tools

Every tool is a backend read, and each one is advertised in tools/list with annotations.readOnlyHint: true so a client can classify it without calling it.

Fix-focused

  • get_context — show the resolved instance / tenant / workspace.

  • list_issues(severity?, rule_id?, category?, search?, page_size?, cursor?) — list issues; paginated, page_size capped at 100.

  • get_issue(issue_id, page_size?, cursor?) — issue detail + assembled rule-level remediation guidance + a page of affected objects; objects is paginated the same way as list_issues.

  • get_finding_detail(issue_id, object_id, detail_id?) — per-finding file path, code snippet, evidence, and inline remediation.

  • find_issues_for_file(path, max_issues?) — issues whose findings reference a given working-tree file (client-side scan; matches by shared path suffix). The scan follows pagination but is bounded — max_issues is capped at 500 and the call at 300 backend requests — and returns a scan block reporting complete, issues_scanned, requests and errors. complete: false means the caps were hit and the file may have findings this result omits; treat it as "unknown", not as "clean", and narrow the search with list_issues filters instead.

  • get_remediation_guidance(rule_name) — rule-level remediation markdown.

Inventory browse

  • list_models | list_agents(name?, severity?, supplier?, library?, page_size?, cursor?)

  • list_mcp_servers(name?, severity?, library?, page_size?, cursor?)

  • list_tools(name?, severity?, page_size?, cursor?)

  • get_model | get_agent | get_tool | get_mcp_server(asset_id) — detail plus attached issues, related assets, and code locations.

Guardrails & LLM-interaction analytics

  • list_guardrail_policies(search?, page?, page_size?) — page-numbered (not cursor-based); page_size capped at 100.

  • get_guardrail_policy(policy_id) — policy detail: name, description, user/assistant detector configuration.

  • get_guardrail_interaction_counts | get_guardrail_outcomes | get_guardrail_categories(agent_id?) — guardrail-decision dashboards across LLM interactions, optionally scoped to one agent.

  • list_llm_interactions(search?, agent_id?, page_size?, cursor?) — prompt/ response pairs with guardrail outcomes; rows are trimmed (long text truncated, per-turn events omitted) for context budget. page_size capped at 100.

  • get_interaction(interaction_id) — one interaction's full detail.

  • list_llm_sessions(agent_id, sort?, sort_dir?, page_size?, cursor?) — grouped conversation turns for one agent (required). page_size capped at 100.

  • get_llm_session(session_id) — one session's aggregate cost/tokens/turns plus the full per-turn list.

ROI / cost-optimization

  • list_roi_agents(page?, page_size?) — per-agent LLM activity summaries (latest_interaction_time, interaction_count). page_size capped at 100.

  • list_roi_interactions(agent_id, since?, until?, page?, page_size?, order?) — one agent's raw LLM interaction rows (with computed cost_usd) — the source data the cost-optimization analyses read. agent_id required; since/until are RFC3339 timestamps. page_size capped at 100.

  • list_roi_analyses(agent_id?, analysis_type?, page?, page_size?, order?) — cost-optimization analysis results (findings + estimated $ savings), latest first. analysis_type is one of tool_bloat, model_optimizer, verbosity, context_cache_waste, retry_loop_waste. page_size capped at 100.

  • get_latest_roi_analyses(agent_id, analysis_types) — the latest finished result per type for one agent, i.e. its current recommendations. Both arguments are required; a type with no finished run is simply absent from the result.

  • get_roi_analysis(analysis_id) — one analysis result's full detail.

Red-teaming / eval

  • list_evaluations(search?, approach?, page?, page_size?, order?) — evaluation definitions (probes/metrics), including red-teaming adversarial probes; approach is probe or metric. Page-numbered; page_size capped at 100.

  • get_evaluation(evaluation_id) — full definition detail, including attack_techniques / adversarial_goals / num_prompts / max_turns for adversarial-probe evaluations.

  • list_agent_evaluations(agent_id?, evaluation_id?, search?, page?, page_size?, order?) — agent↔evaluation assignments, each with latest_run_status/progress/ summary and a score_trend (last 5 scores). Page-numbered; page_size capped at 100.

  • get_agent_evaluation(agent_evaluation_id) — one assignment's full detail.

  • get_agent_evaluation_summary(agent_id) — one agent's evaluation health rollup: health score, per-category OWASP coverage, and score trend.

  • list_evaluation_runs(evaluation_id?, agent_evaluation_id?, page?, page_size?, order?) — runs; status is queued/running/finished/error. Page-numbered; page_size capped at 100.

  • get_evaluation_run(evaluation_run_id) — one run's detail.

  • list_evaluation_run_results(evaluation_run_id, page?, page_size?, order?) — one run's per-prompt results; status is passed/failed/error/ scored. There is no single-result detail endpoint, so conversation transcripts are trimmed rather than dropped: every turn is kept but each turn's text is truncated to 300 characters. Page-numbered; page_size capped at 100.

  • get_agent_endpoint(agent_id) — an agent's red-teaming target-endpoint config (endpoint_url, endpoint_auth_type, model_type, config); secrets are redacted server-side and always come back empty.

Remediation guidance

Rule-level remediation markdown has no dedicated API — it is served by the instance's web server as static assets at {instance}/assets/docs-remediations/… (the same origin and files the web UI reads). This server fetches them at runtime over HTTP through the shared client and caches them per session; nothing is bundled into the package. When a rule has no docs (or the assets origin is unreachable), fall back to the per-finding remediation text from get_finding_detail.

For offline development or tests, set SWITCH_TRUST_REMEDIATION_DIR to a local directory laid out like the assets (rule-name-to-remediation-folder-map.json + per-rule folders); the loader then reads from disk and never touches the network.

Development

  • Layout: src/switch_trust_mcp/ (src/ layout), tests under test/.

  • Editable install: pip install -e '.[dev]', then run switch-trust-mcp.

  • Docs are fetched from your instance at runtime; for offline work point SWITCH_TRUST_REMEDIATION_DIR at a local copy of the docs directory.

Tests

pytest

Tests are hermetic (httpx MockTransport for the client and the remediation-docs fetch, a fake client + SWITCH_TRUST_REMEDIATION_DIR for the tools), so they need no network or live backend.

Available Tools

37 tools
find_issues_for_fileA

Find issues whose findings reference a given working-tree file.

Convenience for the edit loop: scans up to max_issues issues and returns the findings whose file path matches path (matched by shared path suffix, so an absolute or repo-relative path both work), each with its rule, severity, path, and inline remediation text. The backend cannot filter by file, so this is a client-side scan and may be slow for large workspaces.

The scan is bounded: max_issues is capped at 500 and the whole call at 300 backend requests. Check the returned scan.complete — when it is false the caps were hit and the file may have findings this result does not list, so do not read it as "no issues here". Narrow the search with list_issues filters and follow up on specific issues instead.

Inputs: path (required), max_issues.

get_agentB

Get an agent's detail plus its issues, MCP servers, and code locations.

Inputs: asset_id (required).

get_agent_endpointA

Get one agent's target-endpoint config for red-teaming (endpoint_url, endpoint_auth_type, model_type, config). Secrets (endpoint_credential, endpoint_headers) are redacted server-side and always come back empty.

Inputs: agent_id (required).

get_agent_evaluationC

Get one agent<->evaluation assignment's full detail.

Inputs: agent_evaluation_id (required).

get_agent_evaluation_summaryB

Get one agent's evaluation health rollup: health (score/previous_score), coverage (per-category pass/at-risk/not-run counts), and score trend over time. agent_id is required.

Inputs: agent_id (required).

get_contextA

Show the resolved backend scope (instance, tenant, workspace).

Useful to confirm the API key maps to the workspace you expect before querying issues.

Inputs: no named parameters. Returns: object

get_evaluationB

Get one evaluation definition's full detail, including its config (attack_techniques/adversarial_goals/num_prompts/max_turns for adversarial_probe evaluations).

Inputs: evaluation_id (required).

get_evaluation_runB

Get one evaluation run's detail: status, progress, summary, timestamps.

Inputs: evaluation_run_id (required).

get_finding_detailA

Get per-finding detail: file path, code snippet, evidence, and remediation.

Provide the issue_id and object_id (from get_issue's objects). Omit detail_id to list all findings for that object, or pass one to fetch a single finding.

Inputs: issue_id (required), object_id (required), detail_id.

get_guardrail_categoriesC

Guardrail-detector-category counts across LLM interactions, optionally scoped to one agent.

Inputs: agent_id.

get_guardrail_interaction_countsB

Guardrail-decision counts (ok/blocked/redacted/alerted/errored) across LLM interactions, optionally scoped to one agent.

Inputs: agent_id.

get_guardrail_outcomesA

Guardrail outcome totals across LLM interactions, optionally scoped to one agent. Same underlying data as get_guardrail_interaction_counts, without the per-category breakdown.

Inputs: agent_id.

get_guardrail_policyB

Get one guardrail policy's detail: name, description, and the user/assistant detector configuration.

Inputs: policy_id (required).

get_interactionC

Get one LLM interaction's full detail (prompt, response, guardrail events).

Inputs: interaction_id (required).

get_issueA

Get full detail for one issue plus rule-level remediation guidance.

Returns the issue record, the assembled remediation guidance markdown for the issue's rule (when available), and a page of affected objects (assets). The objects list is paginated the same way as list_issues: page_size is capped at 100, and objects.cursor carries forward to fetch the next page. Use get_finding_detail for the code location of a specific occurrence.

Inputs: issue_id (required), cursor, page_size.

get_latest_roi_analysesA

Get the latest finished ROI analysis result per type for one agent — the agent's current cost-optimization recommendations.

Both agent_id and analysis_types are required. Returns a dict keyed by analysis_type; a type with no finished run yet is simply absent from the result rather than erroring.

Inputs: agent_id (required), analysis_types (required).

get_llm_sessionB

Get one LLM session's detail: aggregate cost/tokens/turns and the full per-turn list.

Inputs: session_id (required).

get_mcp_serverB

Get an MCP server's detail plus its issues and code locations.

Agents using this server are embedded in asset directly (the backend has no standalone "agents" edge for the MCP-server scope).

Inputs: asset_id (required).

get_modelB

Get a model's detail plus its attached issues and code locations.

Inputs: asset_id (required).

get_remediation_guidanceA

Get the rule-level remediation guidance markdown for a rule name.

The rule_name matches the value shown on issues (see get_issue). Returns None guidance for rules without docs — use the per-finding remediation from get_finding_detail in that case.

The guidance is wrapped in the procedure for choosing and applying a remediation; get_issue returns the same docs unwrapped, for browsing.

Inputs: rule_name (required). Returns: object

get_roi_analysisA

Get one ROI analysis result by ID (findings, estimated $ savings, status, timestamps).

Inputs: analysis_id (required).

get_toolB

Get a tool's detail plus its agents, issues, and code locations.

Inputs: asset_id (required).

list_agent_evaluationsA

List agent<->evaluation assignments with their latest-run status.

Filters: agent_id, evaluation_id, search (substring match on name). Each row includes evaluation_name, latest_run_status/progress/summary, and a score_trend (last 5 scores). Page-numbered; page_size is capped at 100. Use get_agent_evaluation for full detail, get_agent_evaluation_summary for the OWASP-coverage/health rollup across all of one agent's evaluations.

Inputs: page, order, search, agent_id, +2 more.

list_agentsB

List inventoried AI agents. Filters: name, severity, supplier, library.

page_size is capped at 100; page with the returned cursor for more.

Inputs: name, cursor, library, severity, +2 more.

list_evaluation_run_resultsA

List one run's per-prompt results (score, status, conversation transcript).

status is one of passed/failed/error/scored. There is no separate detail endpoint for a single result, so conversation turns are trimmed here for context budget rather than dropped: every turn is kept (turn sequence matters for multi-turn attacks) but each turn's text is truncated to 300 chars. For full-fidelity transcript review, use the product UI. Page-numbered; page_size is capped at 100.

Inputs: evaluation_run_id (required), page, order, page_size.

list_evaluation_runsA

List evaluation runs. Filters: evaluation_id, agent_evaluation_id.

status is one of queued/running/finished/error. Page-numbered; page_size is capped at 100. Use get_evaluation_run for one run's full detail and list_evaluation_run_results for its per-prompt results.

Inputs: page, order, page_size, evaluation_id, +1 more.

list_evaluationsA

List evaluation definitions (probes/metrics), including red-teaming adversarial probes.

Filters: search (substring match on name), approach ('probe' or 'metric'). Attack-technique/goal detail for adversarial_probe evaluations lives in each item's config. Page-numbered; page_size is capped at 100. Use get_evaluation for full config detail.

Inputs: page, order, search, approach, +1 more.

list_guardrail_policiesA

List guardrail policies (input/output detector configurations).

Filters: search (substring match on policy name). Page-numbered, not cursor-based — pass the next page number to page through results. page_size is capped at 100. Use get_guardrail_policy for full detail.

Inputs: page, search, page_size.

list_issuesA

List AI-SPM issues for the workspace.

Filters: severity (CRITICAL/HIGH/MEDIUM/LOW/INFORMATIONAL), rule_id, category (vulnerability_category), and search (substring match on rule name). Results are paginated: pass the returned cursor to fetch the next page. page_size is capped at 100. Use get_issue for full detail and remediation guidance on a specific issue.

Inputs: cursor, search, rule_id, category, +2 more.

list_llm_interactionsA

List LLM interactions (prompt/response pairs) with guardrail outcomes.

Filters: search (substring match on prompt text), agent_id. Cursor-paginated: pass the returned cursor to fetch the next page. Rows are trimmed (long prompt/response text truncated, per-turn events omitted) to protect context budget — use get_interaction for full detail on a specific interaction. page_size is capped at 100.

Inputs: cursor, search, agent_id, page_size.

list_llm_sessionsA

List LLM sessions (grouped conversation turns) for one agent (required).

Cursor-paginated; page_size is capped at 100. Use get_llm_session for a session's aggregate cost/tokens/turns plus the full per-turn list.

Inputs: agent_id (required), sort, cursor, sort_dir, +1 more.

list_mcp_serversB

List inventoried MCP servers. Filters: name, severity, supplier, library.

page_size is capped at 100; page with the returned cursor for more.

Inputs: name, cursor, library, severity, +2 more.

list_modelsB

List inventoried AI models. Filters: name, severity, supplier, library.

page_size is capped at 100; page with the returned cursor for more.

Inputs: name, cursor, library, severity, +2 more.

list_roi_agentsB

List agents' LLM activity summaries (latest_interaction_time, interaction_count) for the workspace. Drives ROI/cost-optimization analysis: an agent with no recent activity has nothing new to analyze.

page_size is capped at 100.

Inputs: page, page_size.

list_roi_analysesA

List ROI/cost-optimization analysis results (findings + estimated $ savings), latest first.

Filters: agent_id, analysis_type (tool_bloat, model_optimizer, verbosity, context_cache_waste, retry_loop_waste). page_size is capped at 100. Use get_latest_roi_analyses for just the current recommendation per type, or get_roi_analysis for one result's full detail.

Inputs: page, order, agent_id, page_size, +1 more.

list_roi_interactionsA

List one agent's raw LLM interaction rows (with computed cost_usd) — the source data the ROI cost-optimization analyses read.

agent_id is required. since/until are optional RFC3339 timestamps bounding interaction_time. page_size is capped at 100.

Inputs: agent_id (required), page, order, since, +2 more.

list_toolsB

List inventoried agent tools. Filters: name, severity, supplier, library.

page_size is capped at 100; page with the returned cursor for more.

Inputs: name, cursor, library, severity, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 37 tools

    Disambiguation4/5

    Tools are mostly well-separated by resource and action (list vs get vs summary). The clearest overlap is get_guardrail_interaction_counts vs get_guardrail_outcomes, which the description admits share the same underlying data, and get_remediation_guidance overlaps with the remediation embedded in get_issue. These are minor and the descriptions largely disambiguate.

    Naming Consistency4/5

    Overwhelmingly consistent verb_noun pattern (list_*/get_*) with predictable suffixes like _detail, _summary, _runs, _results. A few deviations: find_issues_for_file breaks the list_ convention, and get_context/get_model are vaguer than their peers. Overall readable and consistent.

    Tool Count3/5

    37 tools is heavy, but the server spans many genuinely distinct domains (guardrails, AI-SPM issues, model/agent/tool/MCP inventory, LLM interactions, ROI, evaluations, red-team endpoints), each with roughly 3-6 tools. It is justified but sits well above the comfortable 3-15 band and risks context bloat.

    Completeness4/5

    The surface is broad and largely complete for a read/analytics security platform: list+get coverage for guardrails, issues, inventory, interactions, sessions, ROI, and evaluations, plus aggregation/summary endpoints. Gaps are minor (no per-result detail endpoint for evaluation results, acknowledged trimming) and agents can work around them.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers