A FastMCP server that provides access to files within the .venv directory that are typically not accessible due to .gitignore rules. This enables AI agents to inspect implementation details of installed packages, improving their ability to understand and work with dependencies.
This project demonstrates how to build an MCP server that enables AI agents to read files from within the .venv directory. It serves as both a practical tool and a template for creating your own MCP servers.
The implementation follows the best practices laid out by Anthropic for building MCP servers, allowing seamless integration with any MCP-compatible client.
The server provides one essential file access tool:
get_file_contents: Read the contents of a file from within the .venv directory, enabling access to implementation details of installed packages
- Python 3.12+
- uv package manager
- Install uv if you don't have it:
pip install uv- Clone this repository:
git clone https://github.com/yourusername/mcp-file-context.git
cd mcp-file-context- Install dependencies:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .Run the server in stdio mode (recommended for local development):
mcp-file-contextRun the server in SSE mode:
mcp-file-context --serverBy default, the server runs on port 8050. You can configure the host and port using the -H and -p flags respectively.
The server automatically registers itself with Cascade when installed in editable mode (pip install -e .). No additional configuration is needed.
If running in SSE mode, configure your MCP client to connect to:
http://localhost:8050
# Reading a package's implementation file
contents = get_file_contents("lib/python3.13/site-packages/fastmcp/__init__.py")MIT
Contributions are welcome! Please feel free to submit a Pull Request.