An open API service indexing awesome lists of open source software.

https://github.com/jmanhype/MCPhoenix

A simplified implementation of the Model Context Protocol (MCP) server using Elixir's Phoenix Framework.
https://github.com/jmanhype/MCPhoenix

Last synced: about 1 month ago
JSON representation

A simplified implementation of the Model Context Protocol (MCP) server using Elixir's Phoenix Framework.

Awesome Lists containing this project

README

        

# MCPheonix

A simplified implementation of the Model Context Protocol (MCP) server using Elixir's Phoenix Framework.

## Overview

MCPheonix provides a server that implements the Model Context Protocol, allowing AI models to interact with your application data and functionality. This implementation is designed to be simple and easy to understand, without heavy dependencies on frameworks like Ash.

## Features

- Server-Sent Events (SSE) stream for real-time notifications
- JSON-RPC endpoint for client requests
- Simple resource system
- Event publish/subscribe mechanism
- Basic tool invocation
- Flux image generation integration
- Dart task management integration
- Extensible MCP server architecture

## Getting Started

### Prerequisites

- Elixir 1.14 or higher
- Erlang 25 or higher
- Phoenix 1.7.0 or higher
- Python 3.9+ (for Flux and Dart integration)
- Node.js 18+ (for Dart MCP server)

### Installation

1. Clone the repository
```bash
git clone https://github.com/yourusername/mcpheonix.git
cd mcpheonix
```

2. Install dependencies
```bash
mix deps.get
```

3. Configure the Flux integration (if using image generation)
- Set up the Flux CLI environment as described in the [Flux Integration](#flux-integration) section

4. Configure the Dart integration (if using task management)
- Set up the Dart MCP server as described in the [Dart Integration](#dart-integration) section

5. Start the server
```bash
mix phx.server
```

The server will be available at http://localhost:4001.

### Adding Custom MCP Servers

MCPheonix is designed to work with multiple MCP servers. This system includes a flexible infrastructure for integrating custom MCP servers through:

1. **Simple JSON Configuration**: Define your server settings in `priv/config/mcp_servers.json`:
```json
{
"mcpServers": {
"your_server_id": {
"command": "/path/to/executable",
"args": ["arg1", "arg2"],
"env": {
"ENV_VAR1": "value1",
"ENV_VAR2": "value2"
},
"tools": {
"your_tool": {
"description": "Description of your tool",
"parameters": [
{ "name": "param1", "type": "string", "description": "Parameter description" }
]
}
}
}
}
}
```

2. **Automatic Server Management**: Servers are automatically loaded and managed during application startup.

For comprehensive implementation details, including the Elixir architecture, server lifecycle management, and protocol handling, see the [Adding MCP Servers](docs/adding_mcp_servers.md) documentation.

## MCP Endpoints

- **SSE Stream**: `GET /mcp/stream`
- Establishes a Server-Sent Events stream for receiving real-time notifications
- Returns a client ID in the response headers

- **JSON-RPC**: `POST /mcp/rpc`
- Accepts JSON-RPC 2.0 requests
- Client ID can be provided in the `x-mcp-client-id` header or will be generated if missing

## Built-in Capabilities