Skip to main content
Glama

search_symbol

Find Python classes, functions, and variables across your project using semantic code analysis to improve navigation and editing accuracy.

Instructions

Search symbols (classes, functions, variables) across the project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The `search_symbol` MCP tool handler searches for symbols in the workspace using the `TyLspClient`.
    @mcp.tool()
    async def search_symbol(query: str) -> str:
        """Search symbols (classes, functions, variables) across the project."""
        client = _get_client()
    
        try:
            symbols = await client.search_workspace_symbols(query)
    
            if not symbols:
                return _not_found(f"No symbols matching '{query}'")
    
            results = []
            for sym in symbols:
                uri = sym.get("location", {}).get("uri", "")
                path = _uri_to_path(uri)
                name = sym.get("name", "?")
                kind = SYMBOL_KINDS.get(sym.get("kind", 0), "Symbol")
                range_info = sym.get("location", {}).get("range", {}).get("start", {})
                line = range_info.get("line", 0) + 1
                col = range_info.get("character", 0) + 1
                container = sym.get("containerName", "")
                results.append({
                    "name": name,
                    "kind": kind,
                    "file": path.name,
                    "path": str(path),
                    "line": line,
                    "column": col,
                    "container": container or None
                })
    
            return _ok({"query": query, "count": len(results), "symbols": results})
    
        except Exception as e:
            return _error(str(e))

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/qinsehm1128/mcp-ty'

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