Skip to content

fpjrh/mcp-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

My MCP Server

A basic MCP (Model Context Protocol) server template demonstrating core capabilities.

Features

Tools

  • echo - Echoes back a message (useful for testing)
  • calculate - Performs basic math operations (add, subtract, multiply, divide)
  • get_info - Returns information about the server

Resources

  • resource://examples/welcome - Welcome message for new users
  • resource://examples/capabilities - JSON description of server capabilities

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Test the server locally:
python my_serv.py

Configuration

Add to Cursor

Add this server to your Cursor mcp.json file:

{
  "mcpServers": {
    "my-mcp-server": {
      "command": "python",
      "args": ["/Users/fpj/Development/python/mcp/my_serv.py"],
      "env": {
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

Configuration Options

You can add environment variables to customize behavior:

"env": {
  "LOG_LEVEL": "DEBUG",
  "CUSTOM_VAR": "value"
}

Development

Project Structure

mcp/
├── my_serv.py          # Main server implementation
├── requirements.txt    # Python dependencies
└── README.md          # This file

Adding New Tools

To add a new tool:

  1. Add the tool definition to list_tools():
Tool(
    name="my_tool",
    description="Description of what it does",
    inputSchema={
        "type": "object",
        "properties": {
            "param": {"type": "string"}
        },
        "required": ["param"]
    }
)
  1. Add the tool handler in call_tool():
elif name == "my_tool":
    param = arguments.get("param")
    # Your logic here
    return [TextContent(type="text", text=f"Result: {param}")]

Adding Resources

To add a new resource:

  1. Add to list_resources():
Resource(
    uri="resource://my/resource",
    name="Resource Name",
    mimeType="text/plain",
    description="What this resource provides"
)
  1. Add the handler in read_resource():
elif uri == "resource://my/resource":
    return "Resource content here"

Usage in Cursor

After adding the server to your mcp.json and restarting Cursor:

  1. Open any file in Cursor
  2. In the chat, you can now use commands like:
    • "Use the echo tool to say hello"
    • "Calculate 15 + 27"
    • "Show me the server capabilities"

The AI will automatically call your MCP server tools!

Debugging

View Logs

Logs are written to stderr. In Cursor:

  1. Go to View → Output
  2. Select your server from the dropdown
  3. View real-time logs

Common Issues

Server not starting:

  • Check that Python 3.8+ is installed
  • Verify dependencies are installed: pip install -r requirements.txt
  • Check the path in mcp.json is correct

Tools not available:

  • Restart Cursor (Cmd/Ctrl + Shift + P → "Developer: Reload Window")
  • Check Output panel for error messages
  • Verify mcp.json syntax is valid

Errors during tool execution:

  • Check the Output panel for stack traces
  • Ensure your tool logic handles edge cases
  • Validate input parameters match the schema

Next Steps

Ideas to Extend This Server

  1. File System Operations

    • Read/write files
    • Search directories
    • File management
  2. API Integrations

    • Connect to external services
    • Fetch data from APIs
    • Send notifications
  3. Database Access

    • Query databases
    • Execute SQL
    • Data analysis
  4. Custom Workflows

    • Automate repetitive tasks
    • Code generation
    • Project scaffolding
  5. System Operations

    • Run shell commands
    • Process monitoring
    • Environment management

Resources

License

MIT

About

Initial MCP server test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages