• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Making an MCP server for the twitch-cli to aid developer experience

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Simulate Twitch Event-Sub Events via Cursor with an MCP Server for the twitch-cli.


When building Twitch integrations—like chat bots, overlays, or EventSub-powered features—testing can be painful without real user actions triggering events. That's where the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

and

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

come in.

In this post, I'll show how I set up a local MCP server using fastmcp, and how I use it to trigger events like a Twitch follow using twitch-cli.

What Is an MCP Server?


In the context of tools like Cursor (and possibly other AI IDEs), an MCP server lets you define custom “tools” in code—these tools can then be called by the AI as part of its workflow.

It’s a simple protocol: your server runs locally and exposes functions with structured inputs/outputs over Server-Sent Events (SSE). When the AI tool calls one of your functions, it hits your server and gets the result.

Using fastmcp to Build a Local MCP Server for Cursor AI + Twitch CLI Integration


If you're using an AI coding tool like

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, you might've come across their support for MCP (Model Context Protocol) servers—a way to define your own tools that the AI can invoke directly while coding.

In this post, I’ll show how I’m using

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

to set up a local MCP server, which I’ve wired up to Twitch CLI. With this, I can write prompts in Cursor like:

Project Structure


I have the following in my repo:

./cursor/mcp.json


This config tells cursor to use my local MCP server:


{
"mcpServers": {
"test": {
"url": "

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

",
"disabled": false,
"autoApprove": []
}
}
}
MCP Server code

from fastmcp import FastMCP, Context
from typing import Dict, Any
import os
import subprocess
import shlex

mcp = FastMCP("twitch-cli")

@mcp.tool("trigger_twitch_follow_event")
async def trigger_twitch_follow_event(user_id: str, ctx: Context) -> Dict[str, Any]:
"""
Trigger a Twitch follow event for a specific user ID.

Args:
user_id (str): The Twitch user ID to trigger the follow event for

Returns:
Dict[str, Any]: Command output or error message
"""
domain = os.getenv("DOMAIN")
password = os.getenv("TWITCH_EVENTSUB_SECRET")
command = f'twitch event trigger follow -t {user_id} -s {password} -F "https://{domain}/twitch-eventsub"'

try:
# Split the command into a list of arguments
args = shlex.split(command)

# Execute the command and capture output
result = subprocess.run(
args,
capture_output=True,
text=True,
check=True
)

return {
"success": True,
"stdout": result.stdout,
"stderr": result.stderr,
"return_code": result.returncode
}
except subprocess.CalledProcessError as e:
return {
"success": False,
"error": str(e),
"stdout": e.stdout,
"stderr": e.stderr,
"return_code": e.returncode
}

if __name__ == "__main__":
mcp.run(transport="sse")`
Running locally

export DOMAIN=

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


export TWITCH_EVENTSUB_SECRET=xxx
python server.py
ask your ide AI code agent “Trigger a Twitch follow event for user 12345”
Images



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Final Thoughts


This workflow has been game-changing for building Twitch integrations. I can now prototype and test my EventSub logic without writing manual cli commands, rather just describe the desired event and targeted Twitch user I want in the Cursor AI Chat agent, and it triggers the action via my local tool.

If you're building tools that benefit from programmatic APIs, local scripts, or devops integrations, fastmcp + Cursor’s tool-calling support is an incredibly powerful setup.**


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу