mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-10-26 06:19:49 +00:00
6b85f6881e
internal/mcp/result.go declares CallToolResult as an alias of mcp-go's type, plus textResult / structuredResult / errorResult / errorResultf wrapping the SDK's four constructors. Every non-test site now goes through it: 78 type references and 18 constructor calls across 17 files. 15 files no longer import the SDK's mcp package at all. This is behavior-neutral by construction (an alias and pure delegation). The initialize and tools/list goldens from unit 1 are byte-unchanged, and the mcp package tests, which cover the tools/call path the goldens do not, pass. Claude-Session: https://claude.ai/code/session_016PXRzXhokr61CLbbu3Txj9
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package mcp
|
|
|
|
import "github.com/mark3labs/mcp-go/mcp"
|
|
|
|
// This file is the SDK seam for tool results (TASK-2306). Every non-test
|
|
// dispatcher names the result type and builds results through what is
|
|
// declared here, so a future SDK swap (the modelcontextprotocol/go-sdk port)
|
|
// changes this file rather than every call site. The wire bytes are pinned
|
|
// by cmd/pad/mcp_wire_golden_test.go.
|
|
|
|
// CallToolResult is the result every tool handler and dispatcher returns.
|
|
// It is an alias, not a new type, so values move to and from mcp-go
|
|
// without conversion.
|
|
type CallToolResult = mcp.CallToolResult
|
|
|
|
// textResult is a successful result carrying plain text.
|
|
func textResult(text string) *CallToolResult {
|
|
return mcp.NewToolResultText(text)
|
|
}
|
|
|
|
// structuredResult is a successful result carrying structured content plus
|
|
// its text rendering, for clients that read only one of the two.
|
|
func structuredResult(structured any, text string) *CallToolResult {
|
|
return mcp.NewToolResultStructured(structured, text)
|
|
}
|
|
|
|
// errorResult is an error result carrying plain text. Prefer NewErrorResult
|
|
// (errors.go), which carries a structured envelope, wherever a code applies.
|
|
func errorResult(text string) *CallToolResult {
|
|
return mcp.NewToolResultError(text)
|
|
}
|
|
|
|
// errorResultf is errorResult with formatting.
|
|
func errorResultf(format string, a ...any) *CallToolResult {
|
|
return mcp.NewToolResultErrorf(format, a...)
|
|
}
|