Skip to main content
Glama

search_text

Find specific text strings in Markdown files and identify their structural locations using semantic search functionality.

Instructions

Performs a semantic search for text strings and returns their structural paths.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
queryYesString to search for

Implementation Reference

  • Core handler function that recursively searches document elements for the query string and returns matching paths, types, and previews.
    def search_text(self, query: str) -> List[Dict[str, Any]]: """Search text across all elements""" query = query.lower() results = [] def walk(elements): for el in elements: if query in el.content.lower(): results.append({ "path": el.path, "type": el.type, "preview": el.content[:100] }) walk(el.children) walk(self.elements) return results
  • Tool registration including input schema (file_path, query) and output schema (results array).
    name="search_text", title="Search Text in Document", description="Performs a semantic search for text strings and returns their structural paths.", inputSchema={ "type": "object", "properties": { "file_path": { "type": "string", "examples": ["./document.md", "/path/to/file.md"] }, "query": { "type": "string", "description": "String to search for", "examples": ["TODO", "urgent", "deadline"] } }, "required": ["file_path", "query"], "additionalProperties": False }, outputSchema={ "type": "object", "properties": { "results": { "type": "array", "description": "List of matching elements with their paths" } } }
  • Dispatch handler in MCP server that calls the search_in_document wrapper with file_path and query.
    elif name == "search_text": res = await search_in_document(file_path, arguments["query"]) return {"content": [TextContent(type="text", text=f"Found {len(res)} matches")], "structuredContent": {"results": res}, "isError": False}
  • Wrapper method in EditTool class that loads the Document instance and delegates to its search_text method.
    async def search(self, file_path: str, query: str) -> List[Dict[str, Any]]: doc = self.get_doc(file_path) return doc.search_text(query)
  • Exported async function imported by server.py, calls the EditTool instance's search method.
    async def search_in_document(file_path: str, query: str): return await _instance.search(file_path, query)

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