95 lines
2.8 KiB
Markdown
95 lines
2.8 KiB
Markdown
|
|
# MCP Servers for Bannerlord Harness
|
||
|
|
|
||
|
|
This directory contains MCP (Model Context Protocol) servers that provide tools for desktop control and Steam integration.
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
MCP servers use stdio JSON-RPC for communication:
|
||
|
|
- Read requests from stdin (line-delimited JSON)
|
||
|
|
- Write responses to stdout (line-delimited JSON)
|
||
|
|
- Each request has: `jsonrpc`, `id`, `method`, `params`
|
||
|
|
- Each response has: `jsonrpc`, `id`, `result` or `error`
|
||
|
|
|
||
|
|
## Servers
|
||
|
|
|
||
|
|
### Desktop Control Server (`desktop_control_server.py`)
|
||
|
|
|
||
|
|
Provides desktop automation capabilities using pyautogui.
|
||
|
|
|
||
|
|
**Tools:**
|
||
|
|
- `take_screenshot(path)` - Capture screen and save to path
|
||
|
|
- `get_screen_size()` - Return screen dimensions
|
||
|
|
- `get_mouse_position()` - Return current mouse coordinates
|
||
|
|
- `pixel_color(x, y)` - Get RGB color at coordinate
|
||
|
|
- `click(x, y)` - Left click at position
|
||
|
|
- `right_click(x, y)` - Right click at position
|
||
|
|
- `move_to(x, y)` - Move mouse to position
|
||
|
|
- `drag_to(x, y, duration)` - Drag with duration
|
||
|
|
- `type_text(text)` - Type string
|
||
|
|
- `press_key(key)` - Press single key
|
||
|
|
- `hotkey(keys)` - Press key combo (space-separated)
|
||
|
|
- `scroll(amount)` - Scroll wheel
|
||
|
|
- `get_os()` - Return OS info
|
||
|
|
|
||
|
|
**Note:** In headless environments, pyautogui features requiring a display will return errors.
|
||
|
|
|
||
|
|
### Steam Info Server (`steam_info_server.py`)
|
||
|
|
|
||
|
|
Provides Steam Web API integration for game data.
|
||
|
|
|
||
|
|
**Tools:**
|
||
|
|
- `steam_recently_played(user_id, count)` - Recent games for user
|
||
|
|
- `steam_player_achievements(user_id, app_id)` - Achievement data
|
||
|
|
- `steam_user_stats(user_id, app_id)` - Game stats
|
||
|
|
- `steam_current_players(app_id)` - Online count
|
||
|
|
- `steam_news(app_id, count)` - Game news
|
||
|
|
- `steam_app_details(app_id)` - App details
|
||
|
|
|
||
|
|
**Configuration:**
|
||
|
|
Set `STEAM_API_KEY` environment variable to use live Steam API. Without a key, the server runs in mock mode with sample data.
|
||
|
|
|
||
|
|
## Configuration
|
||
|
|
|
||
|
|
The `mcp_config.json` in the repository root configures the servers for MCP clients:
|
||
|
|
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"mcpServers": {
|
||
|
|
"desktop-control": {
|
||
|
|
"command": "python3",
|
||
|
|
"args": ["mcp_servers/desktop_control_server.py"]
|
||
|
|
},
|
||
|
|
"steam-info": {
|
||
|
|
"command": "python3",
|
||
|
|
"args": ["mcp_servers/steam_info_server.py"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
Run the test script to verify both servers:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
python3 mcp_servers/test_servers.py
|
||
|
|
```
|
||
|
|
|
||
|
|
Or test manually:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Test desktop control server
|
||
|
|
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | python3 mcp_servers/desktop_control_server.py
|
||
|
|
|
||
|
|
# Test Steam info server
|
||
|
|
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | python3 mcp_servers/steam_info_server.py
|
||
|
|
```
|
||
|
|
|
||
|
|
## Bannerlord Integration
|
||
|
|
|
||
|
|
These servers can be used to:
|
||
|
|
- Capture screenshots of the game
|
||
|
|
- Read game UI elements via pixel color
|
||
|
|
- Track Bannerlord playtime and achievements via Steam
|
||
|
|
- Automate game interactions for testing
|