Skip to main content
Glama

replace_content

Update specific sections in Markdown files using hierarchical paths to maintain document structure while modifying content.

Instructions

Overwrites the content of a specific block. Maintains document structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
pathYes
new_contentYes

Implementation Reference

  • The top-level async handler function for the 'replace_content' tool. It delegates to the EditTool instance's replace method to perform the actual replacement.
    async def replace_content(file_path: str, path: str, new_content: str): return await _instance.replace(file_path, path, new_content)
  • Core helper method in EditTool class that performs the content replacement in the Document object and persists changes to the file.
    async def replace(self, file_path: str, path: str, new_content: str) -> Dict[str, Any]: doc = self.get_doc(file_path) result = doc.replace(path, new_content) if "success" in result: with open(file_path, 'w', encoding='utf-8') as f: f.write(doc.get_content()) return result
  • Schema definition for the 'replace_content' tool, including input and output schemas, provided in the Tool registration.
    Tool( name="replace_content", title="Replace Block Content", description="Overwrites the content of a specific block. Maintains document structure.", inputSchema={ "type": "object", "properties": { "file_path": { "type": "string", "examples": ["./document.md"] }, "path": { "type": "string", "examples": ["Introduction > paragraph 1", "Conclusion", "Features > list 2"] }, "new_content": { "type": "string", "examples": ["Updated paragraph text", "New content here"] } }, "required": ["file_path", "path", "new_content"], "additionalProperties": False }, outputSchema={ "type": "object", "properties": { "success": {"type": "boolean"} } } ),
  • Dispatch/registration logic in the call_tool handler that invokes the replace_content function when the tool is called.
    elif name == "replace_content": res = await replace_content(file_path, arguments["path"], arguments["new_content"]) return {"content": [TextContent(type="text", text="Content replaced")], "structuredContent": res, "isError": "error" in res}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KazKozDev/markdown-editor-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server