{"modulePath":"github.com/rossoctl/cortex/authbridge/authlib","version":"v0.0.0-20260925150928-4ef879cde00f","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package mcpparser\n\n## Types\n\n```go\ntype MCPParser struct {\n\t// contains filtered or unexported fields\n}\n```\nMCPParser parses MCP JSON-RPC 2.0 request bodies and populates pctx.Extensions.MCP with the method, RPC ID, raw params, and the IsAction classification verdict for downstream guardrails.\n\nRecognizes three shapes:\n\n 1. JSON-RPC body (POST /mcp with a valid {jsonrpc, method, ...} payload): populates Method/RPCID/Params. IsAction=true for known action methods (tools/call, prompts/get, resources/read); all other methods leave IsAction at the zero-value false.\n\n 2. Body-less DELETE on a configured path with the Mcp-Session-Id header: MCP Streamable HTTP session termination per spec. Populates Method=$transport/terminate, IsAction=false.\n\n 3. Body-less GET on a configured path: MCP Streamable HTTP server- to-client SSE channel-open. Populates Method=$transport/stream, IsAction=false.\n\nBody-less requests on non-configured paths leave Extensions.MCP nil — the parser can't reliably tell whether they're MCP traffic.\n\n```go\nfunc NewMCPParser() *MCPParser\n```\n\n```go\nfunc (p *MCPParser) Capabilities() pipeline.PluginCapabilities\n```\n\n```go\nfunc (p *MCPParser) Configure(raw json.RawMessage) error\n```\nConfigure decodes the optional \\`paths\\` list and compiles a path matcher used by body-less transport-layer detection. Always initializes the matcher (default paths are applied when omitted) so OnRequest never has to nil-check.\n\n```go\nfunc (p *MCPParser) Name() string\n```\n\n```go\nfunc (p *MCPParser) OnRequest(_ context.Context, pctx *pipeline.Context) pipeline.Action\n```\n\n```go\nfunc (p *MCPParser) OnResponse(_ context.Context, pctx *pipeline.Context) pipeline.Action\n```\nOnResponse is the legacy buffered-path response hook. Because this plugin implements StreamingResponder, pipeline.RunResponse skips it and OnResponseFrame is the dispatch path under all listeners — this method is unreachable from a normal listener. Kept for tests and hypothetical pipelines that call OnResponse directly without going through RunResponse, with a defensive guard against re-recording if the streaming path has already populated state.\n\n```go\nfunc (p *MCPParser) OnResponseFrame(_ context.Context, pctx *pipeline.Context, frame []byte, last bool) pipeline.Action\n```\nOnResponseFrame is the streaming-aware response hook. Listeners invoke it once per SSE frame (text/event-stream) and once with last=true at end-of-stream. application/json responses arrive as a single last=true frame — so the same code handles both shapes.\n\nPer-message recording: for MCP, each frame's payload is one complete JSON-RPC response message. We parse + record per message rather than waiting for end-of-stream, so a long-running tools/call surfaces partial results in the session timeline as they arrive — up to maxStreamObserves rows; beyond that the per-frame Observe is suppressed and a single \\_truncated row is emitted at end-of-stream.\n\n","path":"github.com/rossoctl/cortex/authbridge/authlib/plugins/mcpparser","name":"mcpparser","synopsis":"","isRedistributable":true}
