How does an MCP find-and-replace tool work end to end?
Defining MCP Tools with the Python SDK
Audio flashcard · 0:34Nortren·
How does an MCP find-and-replace tool work end to end?
0:34
The second tool in a document server performs a simple find-and-replace operation on a document. The function takes three parameters: the document ID, the text to find, and the replacement text. The implementation first checks that the document exists and raises an error if it does not. Then it performs a straightforward string replacement on the document's contents and stores the updated version back in the dictionary. The mcp tool decorator exposes this function to Claude with all three arguments described. From Claude's perspective, it just calls a tool with three string arguments and gets back a result indicating success or failure.
github.com