mcp_sse

mcp_sse is a simple library for implementing the Model Context Protocol (MCP) over Server-Sent Events (SSE). This library is based on the MCP specification and facilitates real-time data streaming. Developers can easily create MCP servers and streamline communication with clients.

GitHub Stars

64

User Rating

Not Rated

Favorites

0

Views

31

Forks

17

Issues

2

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Elixir: 1.12以上
Phoenix Framework: 1.5以上(Phoenixアプリケーションの場合)

Installation

Installation

Prerequisites

Elixir: 1.12 or higher
Phoenix Framework: 1.5 or higher (for Phoenix applications)

Installation Steps

1. Add Dependencies

Add the following to your mix.exs:
elixir
def deps do
  [
    {:mcp_sse, "~> 0.1.0"}
  ]
end

2. Add Configuration

Add the following to your config/config.exs:
elixir

Configure MIME types for SSE

config :mime, :types, %{ "text/event-stream" => ["sse"] }

Configure the MCP Server

config :mcp_sse, :mcp_server, YourApp.YourMCPServer

3. Compile the Application

bash
mix deps.get
mix compile

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Elixir version and reinstall dependencies.

Configuration

Configuration

Basic Configuration

Implementing MCP Server

You need to implement the MCPServer behavior. Implement the required callbacks (handle_ping/1 and handle_initialize/2) and any optional callbacks based on the features you want to support.

Example Configuration

elixir
defmodule YourApp.YourMCPServer do
  use MCPServer

  def handle_ping(state) do
    {:ok, state}
  end

  def handle_initialize(params, state) do
    {:ok, state}
  end
end

Examples

Examples

Basic Usage of MCP Server

elixir

Start the server

YourApp.YourMCPServer.start_link()

Calling from Client

javascript
// JavaScript example (Node.js)
const { MCPClient } = require('@modelcontextprotocol/client');

const client = new MCPClient();
await client.connect();

// Execute tool
const result = await client.callTool('toolName', {
  parameter1: 'value1',
  parameter2: 'value2'
});

console.log(result);

Use Cases

Using in applications that require real-time data streaming
Serving as an interface to receive immediate results from AI tools
Building a server to manage requests from multiple clients
Creating a system that retains user-specific data through session management

Additional Resources