Local Development
Set up your development environment for building and testing MCP servers.
Overview
Before deploying to agnexus, it's important to test your MCP server locally. This guide helps you set up a local development environment.
Prerequisites
- Node.js 18+ (for TypeScript/Node.js servers)
- Python 3.11+ (for Python servers)
- Docker (optional, for testing containerized deployments)
Setting Up Your Project
Python Project
-
Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Install FastMCP:
pip install mcp
Node.js Project
-
Initialize project:
npm init -y -
Install dependencies:
npm install -
Install MCP SDK:
npm install @modelcontextprotocol/sdk
Running Locally
Python Server
python main.py
Or with FastMCP:
mcp dev
Node.js Server
node index.js
Or with npm scripts:
npm start
Testing with MCP Inspector
Use the MCP Inspector to test your server:
# For HTTP/SSE servers
npx @modelcontextprotocol/inspector http://localhost:8080
# For STDIO servers
npx @modelcontextprotocol/inspector node index.js
Testing Docker Build
Test your Dockerfile locally:
# Build image
docker build -t my-mcp-server .
# Run container
docker run -p 8080:8080 \
-e NOTION_API_KEY=your_key \
my-mcp-server
# Test
curl http://localhost:8080/health
Environment Variables
Create a .env file for local development:
NOTION_API_KEY=your_key_here
DATABASE_URL=postgresql://localhost:5432/mydb
DEBUG=true
Load in your code:
- Python: Use
python-dotenv - Node.js: Use
dotenv