Codicil.MCP.Tools.FindSimilarFunctions (Codicil v0.7.1)

View Source

Find functions by describing what they do in natural language. Searches using semantic similarity, not exact names.

Use this tool when:

  • You need to find existing functionality by describing its behavior
  • The user asks "how do I" or "where is" questions about code capabilities
  • Checking if functionality already exists before implementing something new

Examples:

  • "functions that validate email addresses"
  • "code that parses JSON responses"
  • "database query builders"

Returns: Ranked list of matching functions (not comprehensive - semantic search results).

Summary

Functions

Find functions semantically similar to a description.

Functions

call(args)

Find functions semantically similar to a description.

Parameters

  • description - Natural language description of desired functionality
  • embeddings_client - Embeddings client (optional, defaults to env var)
  • llm_client - LLM client for validation (optional, defaults to env var)
  • limit - Maximum results to return (default: 10)
  • batch_size - Functions to validate per LLM call (default: 20)
  • vector_limit - Functions to retrieve from vector search (default: 100)

Returns

  • {:ok, text} with formatted list of matching functions
  • {:error, reason} if search fails

Example

iex> SimilarFunctions.call(%{"description" => "calculate sum of numbers"})
{:ok, "Found 3 matching functions:\n1. Math.Calculator.sum/1..."}