Xbox Controller MCP Server

Xbox Controller MCP Server

An MCP server that provides Xbox controller emulation capabilities, allowing users to programmatically control buttons, analog sticks, and triggers through an API interface.

Category
访问服务器

README

Xbox Controller MCP Server

An MCP (Model Context Protocol) server that provides Xbox controller emulation capabilities using FastMCP and vgamepad.

Features

  • Button Control: Press, release, or tap any Xbox controller button
  • Analog Sticks: Control left and right analog stick positions
  • Triggers: Set left and right trigger values
  • State Management: Get current controller state and reset to neutral
  • Simulation Mode: Runs without hardware drivers for testing and development
  • Hardware Mode: Full virtual controller support with ViGEmBus driver
  • Cross-platform: Works on Windows (primary), with potential Linux support

Prerequisites

  • Python 3.12 or higher
  • uv package manager
  • Windows OS (recommended for best vgamepad support)

Installation

Using uv (Recommended)

  1. Clone or download this repository
  2. Install dependencies using uv:
uv sync

This will create a virtual environment and install all dependencies from pyproject.toml.

Alternative: Using pip

If you prefer to use pip:

pip install -r requirements.txt

For Hardware Mode (Optional)

To enable actual controller input (instead of simulation mode):

  1. Install ViGEmBus driver:
    • Download from: https://github.com/ViGEm/ViGEmBus/releases
    • Run ViGEmBus_Setup_x64.exe as Administrator
    • Reboot your system

Without the ViGEmBus driver, the server runs in simulation mode where controller state is tracked but no actual input is sent to the system.

Usage

Running the MCP Server

With uv:

uv run main.py

Or with Python directly:

python main.py

The server will start and listen for MCP connections. It automatically detects whether to run in hardware mode (with ViGEmBus) or simulation mode.

Available Tools

Button Controls

  • press_button(button): Press a controller button
  • release_button(button): Release a controller button
  • tap_button(button, duration=0.1): Tap a button (press and release)

Analog Controls

  • set_left_stick(x, y): Set left stick position (-1.0 to 1.0)
  • set_right_stick(x, y): Set right stick position (-1.0 to 1.0)
  • set_triggers(left, right): Set trigger values (0.0 to 1.0)

State Management

  • reset_controller(): Reset controller to neutral state
  • get_controller_state(): Get current controller state
  • list_available_buttons(): List all available button names
  • get_system_info(): Get system information and setup status

Available Buttons

  • Face Buttons: A, B, X, Y
  • Shoulder Buttons: LB, RB
  • Menu Buttons: BACK, START
  • Stick Clicks: LS, RS
  • D-Pad: DPAD_UP, DPAD_DOWN, DPAD_LEFT, DPAD_RIGHT

Example Usage with MCP Client

# Press the A button
await client.call_tool("press_button", {"button": "A"})

# Move left stick to upper right
await client.call_tool("set_left_stick", {"x": 0.5, "y": 0.5})

# Set both triggers to half press
await client.call_tool("set_triggers", {"left": 0.5, "right": 0.5})

# Tap the X button for 0.2 seconds
await client.call_tool("tap_button", {"button": "X", "duration": 0.2})

# Reset everything
await client.call_tool("reset_controller", {})

Architecture

  • FastMCP: Provides the MCP server framework
  • vgamepad: Handles virtual Xbox controller creation and input injection
  • Pydantic: Data validation and serialization
  • Dual Mode Operation:
    • Hardware Mode: Full virtual controller with ViGEmBus driver
    • Simulation Mode: State tracking without actual input (fallback mode)

Coordinate Systems

Analog Sticks

  • Range: -1.0 to 1.0 for both X and Y axes
  • X-axis: -1.0 (left) to 1.0 (right)
  • Y-axis: -1.0 (down) to 1.0 (up)

Triggers

  • Range: 0.0 (not pressed) to 1.0 (fully pressed)

Project Files

  • main.py: Main MCP server implementation with Xbox controller emulation
  • pyproject.toml: Project configuration and dependencies (uv/pip compatible)
  • requirements.txt: Python dependencies for pip users
  • uv.lock: Lockfile for exact dependency versions (uv)
  • mcp-config.json: MCP client configuration file
  • README.md: This documentation

Configuration for MCP Clients

To use this server with Claude Desktop or other MCP clients, add the configuration from mcp-config.json to your MCP client settings:

{
  "mcpServers": {
    "xbox-controller": {
      "command": "python",
      "args": ["main.py"],
      "cwd": "c:\\Users\\blain\\Documents\\git\\controller_mcp",
      "env": {},
      "description": "Xbox Controller Emulator MCP Server - Provides tools to emulate Xbox controller inputs including buttons, analog sticks, and triggers. Supports both hardware mode (with ViGEmBus) and simulation mode."
    }
  }
}

Using with uv

If you're using uv, you can also configure it to use uv for execution:

{
  "mcpServers": {
    "xbox-controller": {
      "command": "uv",
      "args": ["run", "main.py"],
      "cwd": "c:\\Users\\blain\\Documents\\git\\controller_mcp",
      "env": {},
      "description": "Xbox Controller Emulator MCP Server - Provides tools to emulate Xbox controller inputs including buttons, analog sticks, and triggers. Supports both hardware mode (with ViGEmBus) and simulation mode."
    }
  }
}

Troubleshooting

Hardware vs Simulation Mode

The server automatically detects whether the ViGEmBus driver is available:

  • Hardware Mode: Virtual controller inputs are sent to the system
  • Simulation Mode: Controller state is tracked but no actual input is sent

Check the console output when starting the server to see which mode is active.

Windows

  • Ensure you have the necessary permissions to create virtual devices
  • Some antivirus software may block virtual device creation
  • The first run might require administrator privileges
  • If ViGEmBus installation fails, the server will still work in simulation mode

Gaming Applications

  • Most games should detect the virtual controller automatically (hardware mode only)
  • You can verify the controller is working in Windows' "Game Controllers" settings
  • Some games may require the virtual controller to be the only controller connected
  • In simulation mode, no actual controller input is sent to games

Development and Testing

  • Use simulation mode for testing and development without affecting other applications
  • Use the get_system_info() tool to check the current mode and setup status
  • All MCP tools work in both modes - only the actual input injection differs

Development

Project Structure

The project uses modern Python tooling:

  • uv for fast dependency management and virtual environments
  • pyproject.toml for project configuration
  • FastMCP for MCP server implementation
  • Pydantic for data validation

Adding New Features

The server is built modularly. To add new functionality:

  1. Add methods to the XboxControllerEmulator class in main.py
  2. Create corresponding MCP tools using the @mcp.tool() decorator
  3. Update the documentation
  4. Test in both hardware and simulation modes

Development Setup

  1. Clone the repository
  2. Install development dependencies:
    uv sync --dev
    
  3. Run the server:
    uv run main.py
    

Testing

  • The server includes comprehensive logging for both hardware and simulation modes
  • Test individual functions by running the server and connecting with an MCP client
  • Use the get_system_info() tool to verify the setup
  • All functionality works in simulation mode for testing without hardware dependencies

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选