npm package: @streamflux/mcp-server
Description: StreamFlux MCP Server - Connect AI agents to real-time data streams
Author: StreamFlux Team
Latest version: 0.2.1

# @streamflux/mcp-server

**Connect AI agents to real-time data streams via MCP (Model Context Protocol)**

> Let your AI assistant monitor, analyze, and interact with real-time data.

## Features

### Core Tools
- **list_topics** - List all active topics in your StreamFlux server
- **get_stats** - Get server statistics (connections, throughput, uptime)
- **publish_event** - Publish events to any topic
- **subscribe_sample** - Sample messages from a topic for analysis
- **create_window** - Create time-based windows for event aggregation
- **health_check** - Check server connectivity

### AI-Native Tools
- **analyze_stream** - Analyze topic patterns, message frequency, and health status
- **detect_anomalies** - Monitor topics for unusual activity (spikes, drops)
- **broadcast_ai_event** - Publish AI-tagged events with confidence scores
- **get_stream_summary** - Get AI-friendly overview of all streams with suggested actions

## Installation

```bash
npm install -g @streamflux/mcp-server
# or
pnpm add -g @streamflux/mcp-server
```

## Usage with Cursor

Add to your Cursor MCP settings (`~/.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "streamflux": {
      "command": "npx",
      "args": ["-y", "@streamflux/mcp-server"],
      "env": {
        "STREAMFLUX_URL": "https://api.streamflux.dev",
        "STREAMFLUX_API_KEY": "your-api-key"
      }
    }
  }
}
```

Or with local development server:

```json
{
  "mcpServers": {
    "streamflux": {
      "command": "npx",
      "args": ["-y", "@streamflux/mcp-server"],
      "env": {
        "STREAMFLUX_URL": "http://localhost:8080",
        "STREAMFLUX_API_KEY": "your-api-key"
      }
    }
  }
}
```

## Usage with Claude Desktop

Add to your Claude Desktop config:

**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "streamflux": {
      "command": "npx",
      "args": ["-y", "@streamflux/mcp-server"],
      "env": {
        "STREAMFLUX_URL": "https://api.streamflux.dev",
        "STREAMFLUX_API_KEY": "your-api-key"
      }
    }
  }
}
```

## Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `STREAMFLUX_URL` | StreamFlux server URL | `https://api.streamflux.dev` |
| `STREAMFLUX_API_KEY` | API key for authentication | (optional) |

## Example Prompts

Once configured, you can ask your AI assistant:

### Basic Operations
> "List all active topics in StreamFlux"

> "Publish a test event to the 'orders' topic"

> "Show me the server statistics"

### AI-Native Operations
> "Analyze the orders stream - is it healthy?"

> "Detect any anomalies in my data streams"

> "Broadcast an alert saying 'High CPU detected' to the notifications topic"

> "Give me a summary of all streams with recommended actions"

## Resources

The MCP server also exposes topics as resources. You can ask:

> "What resources are available from StreamFlux?"

Each topic is exposed as a resource with URI format: `streamflux://topics/{topic-name}`

## Development

```bash
# Install dependencies
pnpm install

# Run in development mode
pnpm dev

# Build for production
pnpm build
```

## License

MIT