github-mcp-server icon indicating copy to clipboard operation
github-mcp-server copied to clipboard

fix: accept omitted tool arguments for zero-param tools like get_me

Open advancedresearcharray opened this issue 5 months ago • 3 comments

Summary

  • Treat nil or empty arguments on tools/call as {} before JSON unmarshaling in NewServerToolWithContextHandler
  • Fixes get_me and other zero-parameter tools when MCP clients omit the arguments field entirely instead of sending {}

Closes #2587

Problem

Some MCP clients omit the arguments field (or send an empty byte slice) when calling tools that declare no required parameters. The server previously attempted to unmarshal nil/empty input directly, producing invalid arguments: unexpected end of JSON input before the handler ran.

get_me is the most visible affected tool because its schema declares no required arguments, yet strict clients that omit arguments could not call it successfully.

Changes

  • pkg/inventory/server_tool.go: normalize empty arguments to {} before unmarshaling
  • pkg/inventory/server_tool_test.go: cover nil, empty byte slice, and explicit {} inputs
  • pkg/github/context_tools_test.go: integration test for get_me with omitted arguments
  • pkg/github/helper_test.go: add createMCPRequestWithRawArguments test helper

Test plan

  • [x] go test ./pkg/inventory/... -run EmptyArguments
  • [x] go test ./pkg/github/... -run 'GetMe|OmittedArguments'

advancedresearcharray avatar Jun 06 '26 22:06 advancedresearcharray

Verified locally:

  • go test ./pkg/inventory/... -run EmptyArguments — pass
  • go test ./pkg/github/... -run 'GetMe|OmittedArguments' — pass

Branch is up to date with main. Closed duplicate #2607 in favor of this PR.

advancedresearcharray avatar Jun 06 '26 22:06 advancedresearcharray

Re-verified locally with Go 1.25:

  • go test ./pkg/inventory/... -run EmptyArguments — pass
  • go test ./pkg/github/... -run 'GetMe|OmittedArguments' — pass

Branch is up to date with main. Ready for review.

advancedresearcharray avatar Jun 07 '26 02:06 advancedresearcharray

Merge-ready check-in

This PR looks ready for maintainer review/merge when you have a moment.

  • Change: fix: accept omitted tool arguments for zero-param tools like get_me
  • CI: green / passing
  • Review: REVIEW_REQUIRED (mergeable: MERGEABLE)

Happy to rebase or address any remaining feedback. Thanks for maintaining the project.

advancedresearcharray avatar Jun 12 '26 17:06 advancedresearcharray