{"modulePath":"github.com/rossoctl/cortex/core","version":"v0.0.0-20261203232816-53bd38a4e073","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\nOne response per request: JSON-RPC 2.0 gives a request one response, with a result or an error, not both. The first frame that carries a response wins, as in the buffered path (mcp.ParseResponse). The parser ignores a later response frame, so Result and Err are never both set.\n\n","path":"github.com/rossoctl/cortex/core/plugins/mcpparser","name":"mcpparser","synopsis":"","isRedistributable":true}
