LeanMCP is a local MCP chat runtime that turns tool selection into retrieval using a SQLite-backed vector index.
No Bedrock dependency is required for the retrieval layer.
- Start MCP server (stdio).
- Connect through MCP client.
- Call
tools/list. - Convert MCP tools into internal tool objects.
- Index tools in SQLite vector store.
Result: you have a searchable tool index.
Example:
show me files in this directory
Run vector retrieval over tool metadata in SQLite and get top-K relevant tools.
Example output:
[list_directory, read_file]
Send chat state + user input + only retrieved tools to the decision step.
Either:
- answer directly, or
- emit tool call (name + args)
Forward the chosen tool call to MCP tools/call.
Append tool output back into the working context.
Return user-facing response.
Repeat retrieval -> decision -> tool execution until completion or max rounds.
- Traditional: LLM sees all tools every turn.
- LeanMCP: runtime injects only top-K retrieved tools every turn.
Everything else (tool execution loop via MCP) stays standard.
git clone https://github.com/diyagk01/lean-mcp
cd lean-mcppip install -e .Optional local ONNX embeddings:
pip install -e ".[fastembed]"You need an MCP server command:
lean-mcp-chat --mcp-command python --mcp-args "path/to/your_mcp_server.py --stdio" --db-path rag_mcp.dbRun one query and exit:
lean-mcp-chat --mcp-command python --mcp-args "path/to/your_mcp_server.py --stdio" --query "show me files in this directory"q,exit: quithelp: show helpsync: re-list tools from MCP and refresh SQLite indextools: list indexed toolshistory: show conversation historyclear: clear conversation history
rag_mcp/mcp_stdio.py: stdio MCP client (initialize,tools/list,tools/call)rag_mcp/runtime.py: boot + per-message retrieval/decision/tool looprag_mcp/chat_cli.py: interactive chat interface