Skip to content

feat: add support for meta parameter in listTools#906

Open
smohite04 wants to merge 1 commit intomodelcontextprotocol:mainfrom
smohite04:support-meta-list-tools
Open

feat: add support for meta parameter in listTools#906
smohite04 wants to merge 1 commit intomodelcontextprotocol:mainfrom
smohite04:support-meta-list-tools

Conversation

@smohite04
Copy link
Copy Markdown

@smohite04 smohite04 commented Apr 7, 2026

Add support for meta parameter in listTools method.

Motivation and Context

McpSchema.PaginatedRequest now has a meta field (added in #344), but the client API methods don't expose it. As a result, servers which can accept the meta parameter in list tools cannot be used with java client. The Python SDK already supports passing _meta in tools/list requests:

python
async def list_tools(self, *, cursor=None, meta=None) -> ListToolsResult

This change aligns the Java SDK with the Python SDK and the MCP spec which allows _meta in PaginatedRequestParams.

How Has This Been Tested?

  • Unit tests: McpAsyncClientTests.testListToolsWithCursorAndMeta() and testSyncListToolsWithCursorAndMeta() - verify _meta is correctly serialized in the JSON-RPC request
  • Integration test: AbstractMcpSyncClientTests.testListToolsWithMeta() - verified against the real server-everything MCP server via HttpClientStreamableHttpSyncClientTests (Docker/Testcontainers).

Ran per recommendations

Unit tests (McpAsyncClientTests):
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.467 s
  testListToolsWithCursorAndMeta    -- Time elapsed: 0.031 s  ✅
  testSyncListToolsWithCursorAndMeta -- Time elapsed: 0.006 s  ✅
  testListToolsWithEmptyCursor      -- Time elapsed: 0.360 s  ✅
  (+ 4 existing tests passing)
BUILD SUCCESS


Integration test (HttpClientStreamableHttpSyncClientTests against real 
server-everything via Docker):
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.59 s
  testListToolsWithMeta -- Time elapsed: 0.445 s  ✅
BUILD SUCCESS

Breaking Changes

None. New overloaded methods added; existing listTools(String cursor) behavior unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Closes #907

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.

feat: Add support for meta parameter to list tools call( paginated request already support meta field).

1 participant