QQShield

MCP SERVER

MCP server

39 tools that let Claude Code, Claude Desktop, or any other MCP-capable client read and manage this workspace directly. Every tool calls the exact same route-handler function the REST API calls for the equivalent endpoint — one business-logic layer, two transports.

Why this exists

The server runs as a separate local process (apps/mcp) that imports QShield's models and route handlers directly and talks to the same database — not a second implementation of the product's logic, and not an HTTP client calling the API over the network. Nothing about what a finding, a risk score, or a roadmap wave means is reimplemented for MCP; it can never silently drift from what the dashboard shows.

Setup

  1. Install. Both packages go into the same Python 3.12+ environment:
    cd apps/api && pip install -e .
    cd ../mcp && pip install -e .
  2. Generate an API key. From Settings → API keys, create one. Choose read_only unless the agent needs to create organizations/projects, connect AWS/GitHub/registries, or trigger scans — then choose read_write. The full key is shown exactly once.
  3. Configure your MCP client. Point it at the server over stdio:
    {
      "mcpServers": {
        "qshield": {
          "command": "qshield-mcp",
          "env": {
            "QSHIELD_API_KEY": "qsk_...",
            "DATABASE_URL": "postgresql+psycopg://..."
          }
        }
      }
    }
    DATABASE_URLmust point at the same database the QShield API server uses — this process talks to it directly, not through the API's HTTP layer.

Auth model

  • No per-request Authorization header to manage — QSHIELD_API_KEYis read once per tool call and re-validated against the database every time. A key revoked from the Settings page stops working on this server's very next tool call.
  • Every tool acts as the single user who created the key, in that user's workspace — no way for one key to reach another workspace's data.
  • read_only keys can call any read tool. read_write keys additionally unlock create/update/archive/connect/trigger tools.
  • Connector tools additionally require the acting user to hold QShield's admin role — the same require_admincheck the REST API enforces, reproduced exactly (this does not happen automatically; calling a route function directly, as every MCP tool does, skips FastAPI's dependency-injection checks unless the bridge re-applies them).
  • Every call — successful or not — is logged to an mcp_tool_calls audit table (workspace, key, tool name, a hash of the arguments, and outcome).
  • Each key is rate-limited to 60 tool calls per rolling 60 seconds, in-process only — the counter resets on restart, and two running server instances using the same key each get their own budget. Treat it as a runaway-automation guard, not a hard security boundary; override with QSHIELD_MCP_RATE_LIMIT (0 disables it).

Credentials passing through connector tools

connect_github and connect_container_registryaccept a real bearer secret (a PAT, a registry password) as a tool argument. It passes through this process's memory exactly once, gets encrypted at rest with the same envelope encryption the REST API uses, and is never written to the audit log (which stores only a hash of the argument set). Prefer connect_github's github_app auth method (installation ID only, no PAT) where possible.

Read tools

Available to any valid key, including read_only. Three of these (explain_finding, draft_remediation, ask_qshield) call QShield's AI-assist layer and always return a non-authoritative draft.

list_findingsread_only

List findings for a scan (or the whole workspace), highest risk first.

Arguments

NameTypeDescription
scan_idstring?
severitystring?

MirrorsGET /api/v1/findings

get_finding_migration_changeread_only

Deterministic suggested diff, Jira ticket draft, and GitHub PR draft for one finding.

Arguments

NameTypeDescription
finding_idrequiredstring

MirrorsGET /api/v1/findings/{id}/migration-change

explain_findingread_only

AI-drafted plain-language explanation of a finding, for both an engineer and an executive audience.

Non-authoritative — always a draft requiring human review.

Arguments

NameTypeDescription
finding_idrequiredstring

MirrorsPOST /api/v1/findings/{id}/explain

draft_remediationread_only

AI-drafted migration backlog item: acceptance criteria, rollback plan, open questions.

Arguments

NameTypeDescription
finding_idrequiredstring

MirrorsPOST /api/v1/findings/{id}/draft-remediation

ask_qshieldread_only

Turn a natural-language question into a validated, structured finding filter.

Never generates or executes raw SQL.

Arguments

NameTypeDescription
questionrequiredstring

MirrorsPOST /api/v1/findings/query-plan

list_assetsread_only

List discovered assets for a scan.

Arguments

NameTypeDescription
scan_idrequiredstring

MirrorsGET /api/v1/assets

list_crypto_occurrencesread_only

List every observed cryptographic algorithm occurrence for a scan, with purpose/confidence/quantum-status.

Arguments

NameTypeDescription
scan_idrequiredstring

MirrorsGET /api/v1/crypto-occurrences

list_relationshipsread_only

List asset dependency-graph edges for a scan.

Arguments

NameTypeDescription
scan_idrequiredstring

MirrorsGET /api/v1/relationships

get_evidenceread_only

Fetch one raw evidence record plus everything derived from it.

Arguments

NameTypeDescription
evidence_idrequiredstring

MirrorsGET /api/v1/evidence/{id}

get_scan_roadmapread_only

Migration roadmap (prioritized waves of remediation actions) for a scan.

Arguments

NameTypeDescription
scan_idrequiredstring

MirrorsGET /api/v1/scans/{id}/roadmap

get_dependency_graphread_only

Asset dependency graph for a scan, optionally rooted at one asset.

Arguments

NameTypeDescription
scan_idrequiredstring
rootstring?
depthint1–5, default 2
limitint1–1000, default 500

MirrorsGET /api/v1/graph

list_modulesread_only

Status/coverage of every assessment module for a project's latest real scan.

Arguments

NameTypeDescription
project_idstring?

MirrorsGET /api/v1/modules

list_scansread_only

List scan jobs for the workspace (or one project).

Arguments

NameTypeDescription
project_idstring?

MirrorsGET /api/v1/scans

get_scanread_only

Fetch one scan job's status/coverage/summary.

Arguments

NameTypeDescription
scan_idrequiredstring

MirrorsGET /api/v1/scans/{id}

get_portfolioread_only

List every organization and its projects, with each project's latest assessment status.

Arguments

NameTypeDescription
include_archivedbooleandefault false

MirrorsGET /api/v1/portfolio

get_organization_dashboardread_only

Dashboard summary (average risk, per-project status) for one organization.

Arguments

NameTypeDescription
organization_idrequiredstring

MirrorsGET /api/v1/clients/{id}/dashboard

get_project_risk_historyread_only

Risk-score trend for a project over a date range.

Arguments

NameTypeDescription
project_idrequiredstring
date_fromstring?ISO date
date_tostring?ISO date

MirrorsGET /api/v1/projects/{id}/risk-history

get_project_crypto_agilityread_only

Crypto-agility score for a project.

Arguments

NameTypeDescription
project_idrequiredstring

MirrorsGET /api/v1/projects/{id}/crypto-agility

Organization & project lifecycle

Create, update, and archive organizations and projects. Requires a read_write key.

create_organizationread_write

Create a new organization in the current workspace.

Arguments

NameTypeDescription
namerequiredstring
industryrequiredstring
descriptionstring

MirrorsPOST /api/v1/clients

update_organizationread_write

Update an organization's name/industry/description.

Arguments

NameTypeDescription
organization_idrequiredstring
namerequiredstring
industryrequiredstring
descriptionstring

MirrorsPATCH /api/v1/clients/{id}

archive_organizationread_write

Archive an organization (soft-delete; all history is kept).

Arguments

NameTypeDescription
organization_idrequiredstring

MirrorsPOST /api/v1/clients/{id}/archive

restore_organizationread_write

Restore a previously archived organization.

Arguments

NameTypeDescription
organization_idrequiredstring

MirrorsPOST /api/v1/clients/{id}/restore

create_projectread_write

Create a new project under an organization.

No connector is attached automatically.

Arguments

NameTypeDescription
organization_idrequiredstring
namerequiredstring
descriptionstring
environmentstringdefault "demo"
risk_profilestringdefault "moderate"

MirrorsPOST /api/v1/clients/{id}/projects

update_projectread_write

Update a project's name/description/environment/risk profile.

Arguments

NameTypeDescription
project_idrequiredstring
namerequiredstring
descriptionstring
environmentstring
risk_profilestring

MirrorsPATCH /api/v1/projects/{id}

archive_projectread_write

Archive a project (soft-delete).

Arguments

NameTypeDescription
project_idrequiredstring

MirrorsPOST /api/v1/projects/{id}/archive

restore_projectread_write

Restore a previously archived project.

Arguments

NameTypeDescription
project_idrequiredstring

MirrorsPOST /api/v1/projects/{id}/restore

Connectors

Create and validate AWS/GitHub/git/container-registry connectors. Requires a read_write key AND the acting user must hold QShield's admin role — the same require_admin check the REST API enforces, reproduced exactly (calling a route function directly, as every MCP tool does, does not get this check for free).

connect_awsread_write · admin role

Create and validate (real STS call) an AWS connector.

Arguments

NameTypeDescription
namerequiredstring
modestring"moto" | "aws", default "moto"
endpoint_urlstring?
regionsstring[]?
role_arnstring?
external_idstring?
project_idstring?

MirrorsPOST /api/v1/connectors/aws

get_aws_terraform_templateread_write · admin role

Generate the least-privilege cross-account role Terraform file, plus a fresh external_id.

Arguments

NameTypeDescription
role_namestringdefault "qshield-pqc-readonly"

MirrorsGET /api/v1/connectors/aws/terraform-template

validate_aws_connectorread_write · admin role

Re-run STS validation for an existing AWS connector.

Arguments

NameTypeDescription
connector_idrequiredstring

MirrorsPOST /api/v1/connectors/{id}/validate

connect_githubread_write · admin role

Create and validate a GitHub connector (PAT or GitHub App installation).

Arguments

NameTypeDescription
namerequiredstring
auth_methodrequiredstring"pat" | "github_app"
ownerrequiredstring
reporequiredstring
branchstring?
personal_access_tokenstring?
installation_idstring?
project_idstring?

MirrorsPOST /api/v1/connectors/github

validate_github_connectorread_write · admin role

Re-run validation for an existing GitHub connector.

Arguments

NameTypeDescription
connector_idrequiredstring

MirrorsPOST /api/v1/connectors/{id}/github-validate

connect_git_repositoryread_write · admin role

Create a generic git repository connector.

Arguments

NameTypeDescription
namerequiredstring
repository_urlrequiredstring
branchstring?
access_token_env_varstring?
project_idstring?

MirrorsPOST /api/v1/connectors/git-repository

sync_git_connectorread_write · admin role

Pull the latest commit for a git repository connector.

Arguments

NameTypeDescription
connector_idrequiredstring

MirrorsPOST /api/v1/connectors/{id}/git-sync

connect_container_registryread_write · admin role

Create and validate a container registry connector.

Arguments

NameTypeDescription
namerequiredstring
registry_urlrequiredstring
usernamestring?
password_or_tokenstring?
project_idstring?

MirrorsPOST /api/v1/connectors/container-registry

list_connectorsread_write · admin role

List connectors in the workspace (or one project).

Arguments

NameTypeDescription
project_idstring?

MirrorsGET /api/v1/connectors

update_connectorread_write · admin role

Update a connector's name/regions/enabled state.

Arguments

NameTypeDescription
connector_idrequiredstring
namerequiredstring
regionsrequiredstring[]
enabledbooleandefault true

MirrorsPATCH /api/v1/connectors/{id}

Scan actions

Trigger and run assessments. Requires a read_write key.

trigger_scanread_write

Start an assessment for a connector.

Async — poll get_scan for status.

Arguments

NameTypeDescription
connector_idrequiredstring
modulesstring[]?default ["aws_discovery"]
idempotency_keystring?

MirrorsPOST /api/v1/connectors/{id}/scans

run_scanner_moduleread_write

Run one local scanner module against a target and attach the result to an existing scan.

Arguments

NameTypeDescription
scan_idrequiredstring
modulerequiredstring
target_kindrequiredstring
referencerequiredstring
optionsobject?

MirrorsPOST /api/v1/scanners/run

run_derived_moduleread_write

Run a derived module (key_management, crypto_graph, migration_lab).

Arguments

NameTypeDescription
scan_idrequiredstring
module_keyrequiredstring

MirrorsPOST /api/v1/scans/{id}/derived-modules/{module_key}

Troubleshooting

"QSHIELD_API_KEY is not set"— the environment variable wasn't passed to the server process. Check your MCP client's server config.

"QSHIELD_API_KEY is invalid, unknown, or has been revoked" — generate a new key from Settings → API keys.

"This API key is read_only; this action requires a read_write key" — generate a new key with the read_write scope.

"This action requires an admin role" — only connector tools require this; the account that created the key must have the admin role in QShield.

"Rate limit exceeded" — wait a moment, or raise QSHIELD_MCP_RATE_LIMIT on the server process.