Function Lookup MCP Server
A Model Context Protocol (MCP) server that helps AI assistants like Copilot or Claude analyze code by looking up function usage within source files.
Features
- Function Lookup: Find where and how specific functions are used in your codebase
- Supports Python and TypeScript/TSX files
- Built with the official MCP SDK for standardized protocol support
- Uses regex pattern matching for reliable function search
Installation
-
Clone this repository:
git clone <repository-url from this repository> cd MCP_OA -
Install dependencies:
npm install --legacy-peer-depsNote: The
--legacy-peer-depsflag is required to handle dependency conflicts between packages.
Building
Build the TypeScript code:
npm run build
This compiles the source code to the dist directory.
Setting Up with an MCP-Compatible Assistant
VS Code Copilot Extension
- Open VS Code settings
- Search for "MCP" or "Model Context Protocol"
- Add a new server with these settings:
- Server Name:
function-lookup(or any name you prefer) - Command:
node - Arguments:
dist/src/index.js(path to the compiled dist/src/index.js on your machine) - Environment Variables: None needed
- Server Name:
Claude Code Extension or Amp Codesearch Direct Extension usage
- Open Claude or User settings in VS Code
- Navigate to the "MCP Servers" section
- Add a new server with:
{ "mcpServers": { "function-lookup": { "command": "node", "args": ["dist/src/index.js"] } } }
Using the Tools
functionLookup
This tool finds occurrences of a specific function within a source file.
Parameters:
functionName: The name of the function to look forfilePath: Path to the file to analyze
Example prompt:
Please find where the 'calculate_sum' function is used in src/calculator.py.
Implementation Details
The server uses regex pattern matching to find function occurrences in files. The implementation is:
- Reads the specified file
- Uses a regular expression to find all occurrences of the function name as a word boundary
- Returns the line numbers where the function is found
- Handles errors gracefully with appropriate messages
Testing
The project includes a comprehensive test suite in the tests directory.
To run the tests:
-
Build the project:
npm run build -
Run the test client:
npm run test
The test client will:
- Connect to the MCP server
- List available tools
- Run a series of test cases against the
functionLookuptool:- Finding functions in the main source code
- Finding functions in test sample files
- Testing with non-existent functions
- Display detailed results for each test case
- Show a test summary at the end
Test Files
tests/test-client.ts: The main test runner that connects to the server and runs test casestests/sample.ts: A sample file with multiple functions for testing the lookup functionality
You should see output showing the lines where different functions are found in the specified files and a summary of passed/failed tests.
Manual Testing with MCP Client
You can also test the server by running it directly (note that this will run the server to allow manual testing):
npm run start
And then connect to it using any MCP-compatible client.
Troubleshooting
If you encounter connection issues with the MCP server:
- Make sure you're using the correct path to the compiled script (
dist/src/index.js) - Check that all dependencies are installed correctly
- Look for detailed error messages in the server logs
- If you see protocol version errors, make sure your client is compatible with the MCP server
Recommend MCP Servers 💡
clearml-mcp
A lightweight Model Context Protocol (MCP) server that enables AI assistants to interact with ClearML experiments, models, and projects, providing comprehensive ML experiment context and analysis directly in AI conversations.
dart-mcp-server
An AI Model Context Protocol (MCP) server for Dart AI, providing tools for task and document management.
agent_mcp.cli
Agent-MCP is a framework for creating multi-agent systems that enables coordinated, efficient AI collaboration through the Model Context Protocol (MCP). The system is designed for developers building AI applications that benefit from multiple specialized agents working in parallel on different aspects of a project.
discord-mcp
MCP server for Discord integration, enabling AI assistants to interact with Discord seamlessly.
nazar256/combine-mcp
An MCP aggregator that combines multiple MCP servers into a single stdio interface for clients like Cursor
mcp-vertexai-search
A MCP server to search documents using Vertex AI with grounding capabilities