Skip to content

Conversation

@burmudar
Copy link
Contributor

@burmudar burmudar commented Nov 27, 2025

Define structures to parse the mcp tool json

  • define general Schema which can be used for Input and Out schema definitions
  • define SchemaValue interface to unitfy types under one umbrella
  • specilzied schema types: SchemaObject, SchemaArray, SchemaPrimitve
  • special handling for when items: true

Part of SRCH-2167

Test plan

Added testcase and parsed the dumped json

@burmudar
Copy link
Contributor Author

burmudar commented Nov 27, 2025

)

//go:embed mcp_tools.json
var _ []byte
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporarily ignored

@burmudar burmudar marked this pull request as ready for review December 2, 2025 14:40
@burmudar burmudar requested a review from a team December 2, 2025 14:40
@burmudar burmudar changed the title parse mcp tool json feat(mcp): parse mcp tool json Dec 2, 2025
@burmudar burmudar force-pushed the wb/mcp-tool-list-dump branch from 52465c1 to ebb49f7 Compare December 5, 2025 09:35
@burmudar burmudar force-pushed the wb/parse-mcp-tool-json branch 2 times, most recently from e9da8bb to ea3325b Compare December 5, 2025 10:25
@burmudar burmudar force-pushed the wb/mcp-tool-list-dump branch from ebb49f7 to 9fb4691 Compare December 8, 2025 10:07
@burmudar burmudar force-pushed the wb/parse-mcp-tool-json branch from ea3325b to 89494c8 Compare December 8, 2025 10:08
OutputSchema SchemaObject `json:"outputSchema"`
}

type RawSchema struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: you might as well only define the fields on these structs you will actually end up reading.

And my favourite nit: probably not used outside of this package so don't export.

return nil, err
}

tools := map[string]*ToolDef{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: is there any chance the tool order matters? I think in the backend we also use a map and just sort by name when serializing for determinism, but I can't remember.

Comment on lines +31 to +33
type SchemaValue interface {
ValueType() string
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we remove SchemaValue and just use a normal go interface? Then we just have some sort of standard set of go types we could marshal into (same as how the json library works in go)

"testing"
)

func TestLoadToolDefinitions(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a nicer test here would probably just load in mcp_tools.json and then assert on some stable tool's properties. eg the read file tool likely won't change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants