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 💡
@flipt-io/mcp-server-flipt
A Model Context Protocol (MCP) server for Flipt, enabling AI assistants to interact with feature flags.
kanban-mcp
MCP server providing kanban-based task management state for AI-driven development
mlb-api-mcp
A Model Context Protocol (MCP) server that provides comprehensive access to MLB statistics and baseball data through a FastMCP-based interface.
mcp-local-rag
"primitive" RAG-like web search model context protocol (MCP) server that runs locally. ✨ no APIs ✨
MSAdministrator/enrichment-mcp
An MCP server that enriches security observables using various security services like VirusTotal, Shodan, and Hybrid Analysis
mcp-twikit
A Model Context Protocol (MCP) server for interacting with Twitter.