Documentation
¶
Index ¶
- type MCPParser
- func (p *MCPParser) Capabilities() pipeline.PluginCapabilities
- func (p *MCPParser) Configure(raw json.RawMessage) error
- func (p *MCPParser) Name() string
- func (p *MCPParser) OnRequest(_ context.Context, pctx *pipeline.Context) pipeline.Action
- func (p *MCPParser) OnResponse(_ context.Context, pctx *pipeline.Context) pipeline.Action
- func (p *MCPParser) OnResponseFrame(_ context.Context, pctx *pipeline.Context, frame []byte, last bool) pipeline.Action
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MCPParser ¶
type MCPParser struct {
// contains filtered or unexported fields
}
MCPParser 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.
Recognizes three shapes:
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.
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.
Body-less GET on a configured path: MCP Streamable HTTP server- to-client SSE channel-open. Populates Method=$transport/stream, IsAction=false.
Body-less requests on non-configured paths leave Extensions.MCP nil — the parser can't reliably tell whether they're MCP traffic.
func NewMCPParser ¶
func NewMCPParser() *MCPParser
func (*MCPParser) Capabilities ¶
func (p *MCPParser) Capabilities() pipeline.PluginCapabilities
func (*MCPParser) Configure ¶
func (p *MCPParser) Configure(raw json.RawMessage) error
Configure 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.
func (*MCPParser) OnResponse ¶
OnResponse 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.
func (*MCPParser) OnResponseFrame ¶
func (p *MCPParser) OnResponseFrame(_ context.Context, pctx *pipeline.Context, frame []byte, last bool) pipeline.Action
OnResponseFrame 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.
Per-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.