twitch-chat-mcp
The Twitch Chat MCP Server is designed to integrate Claude desktop with Twitch chat, allowing real-time interaction and message management through a comprehensive API. Key features include connecting via HTTP API, observing and sending messages in Twitch channels, and providing chat activity summaries.
Twitch Chat MCP Server
A Message Control Protocol (MCP) server that connects Claude desktop with Twitch chat, allowing Claude to read and interact with Twitch chat.
Features
- Connect with Claude desktop via HTTP API
- Authenticate with Twitch API (browser-based OAuth flow)
- Observe Twitch chat in specified channels
- Send messages to Twitch chat
- Parse user queries to determine relevant Twitch channels
- Provide summaries of chat activity
Project Structure
docs/
- Documentationarchitecture.md
- System architecturedecisions.md
- Decision logchallenges.md
- Implementation challenges
src/
- Source codemcp/
- MCP server componentstwitch/
- Twitch integration componentsclaude/
- Claude integration componentstools/
- Tool definitions for Claude
tests/
- Test suiteconfig/
- Configuration filespublic/
- Web UI for authenticationllm/
- LLM-related filesseed_prompt.md
- Original development prompt
Setup
-
Create a Twitch application in the Twitch Developer Console
- Set the OAuth Redirect URL to
http://localhost:3000/auth/twitch/callback
- Note your Client ID
- Set the OAuth Redirect URL to
-
Install dependencies:
npm install
-
Copy the example environment file and fill in your Twitch app details:
cp .env.example .env
Then edit
.env
with at least your Twitch Client ID:TWITCH_CLIENT_ID=your_client_id_from_twitch_dev_console
-
Build the project:
npm run build
-
Start the server:
npm start
-
Open your browser and go to
http://localhost:3000
-
Click "Login with Twitch" to authenticate the application
Authentication
The application supports two ways to authenticate with Twitch:
1. Browser-based OAuth Flow (Recommended)
- Start the server
- Visit
http://localhost:3000
in your browser - Click "Login with Twitch"
- Follow the Twitch authentication process
- After successful authentication, the token will be stored in the session
2. Manual Token Configuration
If you prefer to set up manually:
- Get an OAuth token from Twitch Token Generator
- Make sure to request
chat:read
andchat:write
scopes
- Make sure to request
- Add the token to your
.env
file:TWITCH_OAUTH_TOKEN=oauth:your_token_here TWITCH_USERNAME=your_bot_username
Development
Run in development mode with automatic reloading:
npm run dev
Run linting:
npm run lint
Run tests:
npm test
API Endpoints
Authentication
GET /auth/twitch/login # Redirects to Twitch for authorization
GET /auth/twitch/status # Returns current authentication status
GET /auth/twitch/logout # Logs out and clears the session
Tool Definitions
GET /tools/definitions
Returns the available tools and their parameter definitions.
Tool Execution
POST /tools/execute
Execute a tool with the specified parameters.
Example:
{
"name": "observe_twitch_chat",
"parameters": {
"channel": "xqc",
"duration": 60000
}
}
Claude Integration
To use this server with Claude, configure Claude to use the following tool definition:
{
"tools": [
{
"name": "observe_twitch_chat",
"description": "Observe Twitch chat in a specific channel for a configurable duration",
"input_schema": {
"type": "object",
"properties": {
"channel": {
"type": "string",
"description": "The Twitch channel to observe (without the # prefix)"
},
"duration": {
"type": "integer",
"description": "Duration to observe in milliseconds (default: 60000 = 1 minute)"
}
},
"required": ["channel"]
}
},
{
"name": "send_twitch_message",
"description": "Send a message to a Twitch channel",
"input_schema": {
"type": "object",
"properties": {
"channel": {
"type": "string",
"description": "The Twitch channel to send a message to (without the # prefix)"
},
"message": {
"type": "string",
"description": "The message to send to the channel"
}
},
"required": ["channel", "message"]
}
}
]
}
License
MIT