The Problem

Autonomous LLM agents need a reliable way to discover and select the right tool for a given task. This repository supplies the MCP‑Zero pipeline – a set of Python modules that compute embeddings, match tools by similarity, and surface the most relevant server‑tool pairs. However, the codebase is currently missing automated quality gates, reproducible dependency management, and several internal quality nuggets that hinder adoption in a production pipeline.

What This Does

MCP‑Zero consists of two sub‑projects: MCP‑zero (14 files, 7 code files) and MCP‑tools (4 files, 1 code file). The core flow starts at the entry point

main  MCP-tools/build_data/get_server_summary.py:55  reaches 21 function(s)

which invokes extract_info_for_readme → a network call via requests.post to fetch server metadata, then persists a JSON summary. Embedding similarity is performed by cosine_similarity (called from 4 places) and get_embedding (called from 3 places) both defined in MCP-zero/matcher.py. Tool selection proceeds through select_target_tool and sample_tools in MCP-zero/sampler.py, while test_llm_retrieval in MCP-zero/experiment_mcptools.py exercises the end‑to‑end retrieval loop.

The module graph shows a modest hub: matcher.py defines __init__, load_data, setup_openai_client, extract_tool_assistant, and get_embedding; it is imported by test_matcher.py and called from main. experiment_apibank.py and experiment_mcptools.py each expose a handful of utility functions (load_json_data, load_system_prompt, read_text_file, run_grid_search) but do not participate in the primary matching pipeline.

How It Is Wired

  • Entry point → main in MCP-tools/build_data/get_server_summary.py triggers data extraction, embedding generation, and similarity matching.
  • Network effect – extract_info_for_readme issues a requests.post to an external server; all other computation stays local.
  • Embedding pipeline – setup_openai_client (in MCP-zero/matcher.py) creates the OpenAI client; get_embedding and cosine_similarity convert tool descriptions into vectors and compute similarity scores.
  • Tool selection – select_target_tool (in MCP-zero/sampler.py) uses the similarity matrix to pick the best match; sample_tools provides random sampling for exploration.
  • Test harness – test_matcher.py loads test cases from test_cases.jsonl and exercises match_servers → cosine_similarity.

The internal call graph contains 45 resolved edges; the most‑connected functions are cosine_similarity (4 callers), get_embedding (3 callers), and extract_tool_assistant (2 callers). No circular dependencies are present, but the deep nesting (max depth 6) in MCP-tools/build_data/get_server_summary.py, MCP-zero/experiment_apibank.py, and MCP-zero/experiment_mcptools.py makes control flow hard to follow.

How To Use It

Setup

git clone https://github.com/moses-y/Autonomous-LLM-Agents.git
cd Autonomous-LLM-Agents
python -m pip install -r requirements.txt   # pins the needed Python packages

The only external dependency is an OpenAI API key; set OPENAI_API_KEY in the environment before running any script that calls setup_openai_client (defined in MCP-zero/matcher.py).

Configuration

  • No separate config file is present; all parameters (e.g., similarity threshold, grid‑search ranges) are hard‑coded or passed as arguments to the entry‑point functions.
  • The requirements.txt file lists the exact package versions needed for reproducible builds.

Running it

  • To generate the server summary dataset: ``bash python MCP-tools/build_data/get_server_summary.py ``
  • To test the matcher with the provided test cases: ``bash python MCP-zero/test_matcher.py ``
  • To experiment with the API‑bank or MCP‑tools pipelines: ``bash python MCP-zero/experiment_apibank.py python MCP-zero/experiment_mcptools.py ``

What the code touches outside itself

  • main → extract_info_for_readme performs a network POST request.
  • Several functions (read_text_file, extract_tool_assistant, format_tools_as_functions) read or write local JSON/LLM‑prompt files under MCP-zero/ and MCP-tools/.
  • setup_openai_client calls the OpenAI inference API for embedding generation.

Real‑World Use

An autonomous agent tasked with “planning a dinner party” can invoke MCP‑Zero’s matching layer: given a natural‑language query, the system embeds the query, ranks candidate MCP servers by cosine_similarity, and returns the top‑scoring tool (e.g., a recipe‑generation function). The agent then calls that tool’s API, achieving a closed‑loop “tool‑discover‑and‑execute” workflow with minimal manual configuration.

Code Health & Issues

  • [HIGH] Add a workflow that builds and tests this repository – evidence: 8 source files, no CI configuration; every change merges without a build gate, a pattern seen across 499 repositories in this estate.
  • [MEDIUM] Enable Dependabot or Renovate – evidence: 1 manifest (requirements.txt), no update bot configured; without a bot patches remain unapplied until manual audit, which across 1,322 repositories means never.
  • [MEDIUM/clarity] Duplicated code blocks – files MCP-zero/experiment_mcptools.py and MCP-zero/matcher.py each contain four repeated 6‑line blocks; extract shared helpers to DRY the logic.
  • [MEDIUM/resilience] Broad exception handling – MCP-tools/build_data/get_server_summary.py and MCP-zero/reformatter.py catch Exception broadly, swallowing errors indiscriminately; replace with specific exception types and re‑raise or log the rest.
  • [MEDIUM/cognitive_load] Deep nesting – max indentation depth 6 in three files; flatten with early returns/guard clauses or extract inner blocks.

The Bottom Line

MCP‑Zero provides a functional prototype for active tool discovery, with clear embedding‑based similarity and a single entry point that fetches server data and ranks tools. The codebase is modest in size but lacks CI/CD, a lockfile, and several quality safeguards (duplicate logic, bare exception catches, deep nesting). It is suitable for experimentation and early integration, but any production deployment should add a CI pipeline, Dependabot monitoring, and the suggested refactorings to improve maintainability and resilience.