-
Notifications
You must be signed in to change notification settings - Fork 795
_meta information present in the CallToolRequest #405
vignesh1234567
started this conversation in
General
-
Pre-submission Checklist
- I have checked that this question would not be more appropriate as an issue in a specific repository
- I have searched existing discussions and documentation for answers
Question Category
- Protocol Specification
- SDK Usage
- Server Implementation
- General Implementation
- Documentation
- Other
Your Question
How can I access the _meta information present in the CallToolRequest and use it within the tool execution logic?
I need to send tokens through the _meta field and consume them during tool execution.
Currently, I'm using:
tool.call().apply(exchange, callToolRequest.arguments())
However, it seems that the full request (including _meta) isn't being passed through. Is there a way to retrieve the complete request, including the metadata?
private McpServerSession.RequestHandler toolsCallRequestHandler() {
return (exchange, params) -> {
McpSchema.CallToolRequest callToolRequest = objectMapper.convertValue(params,
new TypeReference<McpSchema.CallToolRequest>() {
});
Optional<McpServerFeatures.AsyncToolSpecification> toolSpecification = this.tools.stream()
.filter(tr -> callToolRequest.name().equals(tr.tool().name()))
.findAny();
if (toolSpecification.isEmpty()) {
return Mono.error(new McpError("Tool not found: " + callToolRequest.name()));
}
return toolSpecification.map(tool -> tool.call().apply(exchange, callToolRequest.arguments()))
.orElse(Mono.error(new McpError("Tool not found: " + callToolRequest.name())));
};
}
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment