How to call an MCP request from inside a tool method #806
-
Pre-submission Checklist
Question Category
Your QuestionHi, I’m new to MCP and AI development, and I’m stuck on one thing. I have created a tool with [McpServerTool], but inside that tool method I want to call the AI agent directly and get the response back into the same method. I tried using RequestContext.SendMessageAsync but I can’t figure out the correct way to both send the request and capture the response message. Basically: From inside my tool, I want to send a message to the MCP agent. Then I want to get the response and use it inside the tool method (e.g. save it to a file). If anyone can share the proper way to do this (or point me to a reference/example), it would help a lot 🙏. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can take a look at the Elicitation use in the samples folder. This is how you can request extra information from the user during a tool call. |
Beta Was this translation helpful? Give feedback.
-
Thanks your hint helped me check the samples again and I got it working.
Now I can call the agent inside the tool and use the response directly. |
Beta Was this translation helpful? Give feedback.
You can take a look at the Elicitation use in the samples folder. This is how you can request extra information from the user during a tool call.