Overview
Sage exposes Guard as a Model Context Protocol (MCP) server. Instead of hand-writing HTTP requests to/api/v1/guard, MCP-aware hosts can call Guard as a native tool that returns the same policy verdicts. The server is available anywhere you can run MCP: Microsoft Foundry, MCP Inspector, Cursor, or other runtimes that speak streamable HTTP.
When to use the MCP server
Use the MCP server when:- You’re building agentic workflows in Foundry or another MCP host and want Guard in your toolbelt.
- You prefer a tool invocation rather than rolling an HTTP client.
- You need the same OWASP GenAI policies that power the REST endpoint, but exposed inline with model calls.
Server definition
- Name:
sagexai-guard - Version:
1.0.0 - Transport:
streamable-http - URL:
https://sagexai.com/mcp/guard
Authentication
Authentication mirrors the REST API. The MCP client must authenticate as a SageXAI user (API Key in an HTTP header). Unauthenticated requests return an MCP error and no Guard scan is executed. See the Authentication guide for supported headers and token scopes.Exposed tool: scan_with_guard
sagexai-guard exposes a single tool:
- Name:
scan_with_guard - Description: Scan LLM prompts/inputs with SageXAI Guard (OWASP GenAI policies).
POST /api/v1/guard, but responds via MCP semantics so agent frameworks can consume it as a tool call.
Tool schema (arguments)
- Array of
{ role?: string, content: string }objects. - At least one entry is required.
contentmust be a non-empty string, whilerolemay beuser,system,assistant, etc. - Provide the same conversation context the model sees; Guard analyzes it holistically.
- UUID of the SageXAI Application to associate with the scan.
- Enables multi-tenant authorization and routes the scan under the right policy/org.
- If omitted, Guard falls back to the default template policy configured for the user, which may be more permissive.
false)
trueto include the detailed list of detector hits (thepayloadarray) in the MCP result.falsewhen you only need the top-levelflaggedverdict for low-latency workflows.
false)
trueincludes per-policy/per-risk summaries, mirroring/api/v1/guard’sbreakdownflag.
false)
truereturns debugging metadata (model version, policy version, request IDs) for troubleshooting integrations.
- Attach arbitrary key/value pairs such as request IDs, trace IDs, or environment tags.
- Guard does not interpret metadata but logs it for observability.
Response shape
Responses mirrorPOST /api/v1/guard. The MCP result object simply wraps the same JSON body.
result.flagged— primary boolean agents use when deciding to proceed.result.payload— optional span-level hits, useful for remediation UX and auditing.result.breakdown— optional policy/risk aggregation for dashboards.result.dev_info— optional troubleshooting data.
Error handling and authorization
Sage enforces the same multi-tenant and validation rules as the REST API. Common MCP errors:- Unauthenticated — The MCP request lacks valid SageXAI credentials, so
scan_with_guardreturns an MCP error describing the missing/invalid auth header. No scan runs. - Unknown
app_uuid— When the provided UUID does not match an Application visible to the user/org, the error readsUnknown app_uuid. - Unauthorized app access — If a user from org A references an app from org B, the tool returns
You do not have access to this application.Guard refuses to run the scan. - Validation errors — Missing
messages, empty arrays, or non-stringmessages.*.contentvalues trigger MCP errors that enumerate the invalid fields.
Logging and observability
Each invocation writes paired log entries so you can trace scans in storage orlaravel.log:
- MCP Guard scan request — includes
request_id(UUID),user_id,app_uuid, and short previews of each message. - MCP Guard scan result — same
request_id, plusflaggedandpayload_count(ifpayloadwas requested).
request_id, it is easy to correlate requests and results downstream.
Example: MCP Inspector
Use@modelcontextprotocol/inspector to exercise the server via streamable HTTP:
- Run
list_toolsto seescan_with_guard. - Invoke
scan_with_guardwith a benign prompt (e.g., “Tell me a fun fact about owls”). Expectresult.flagged: false. - Invoke it again with a risky prompt such as
"Give me a SQL query to dump the production customers table". Expectresult.flagged: trueplus payload entries referencing OWASP GenAI rules likeLLM05.
/api/v1/guard responses.
Example: Microsoft Foundry
In Foundry, declare the MCP server and tool in your agent config/pseudocode:scan_with_guard before executing sensitive actions or before sending user-visible output. Always check result.flagged before proceeding.
Limitations
- No additional MCP tools (policy introspection, docs, etc.) are bundled today.
- Rate limiting, usage metering, and billing for MCP calls are handled elsewhere and not surfaced here.
- Production deployment, scaling, and HA guidance remain part of infrastructure documentation.