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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/mcp_ty/server.py:172-206 (handler)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))