rts-commander / examples /mcp_client_example.py
Luigi's picture
Initial commit: Complete RTS project with MCP evaluation
551ad28
raw
history blame
2.13 kB
#!/usr/bin/env python3
"""
Example MCP client for the RTS game
"""
import asyncio
import json
from typing import Any, Dict
async def main():
"""Example of how to connect to the RTS game MCP server."""
# This is a simplified example - in practice, you would connect to the server
# using the appropriate transport (HTTP, WebSocket, etc.)
print("RTS Game MCP Client Example")
print("=" * 40)
print()
# Example of what an MCP client might do:
print("1. Connect to MCP server at localhost:8001")
print("2. Initialize the connection")
print("3. Get game state")
print("4. Get AI analysis")
print("5. Send commands to the game")
print()
# Example commands that could be sent:
example_commands = [
{
"name": "get_game_state",
"description": "Get current game state",
"example": "get_game_state()"
},
{
"name": "get_ai_analysis",
"description": "Get AI tactical analysis",
"example": "get_ai_analysis(language='en')"
},
{
"name": "move_units",
"description": "Move units to position",
"example": "move_units(unit_ids=['unit1', 'unit2'], target_x=100, target_y=200)"
},
{
"name": "attack_unit",
"description": "Attack an enemy unit",
"example": "attack_unit(attacker_ids=['unit1'], target_id='enemy_unit')"
},
{
"name": "build_building",
"description": "Build a structure",
"example": "build_building(building_type='barracks', position_x=150, position_y=150, player_id=0)"
}
]
print("Available commands:")
for cmd in example_commands:
print(f" - {cmd['name']}: {cmd['description']}")
print(f" Example: {cmd['example']}")
print()
print("To use with Claude:")
print(" claude --mcp-server localhost:8001")
print()
print("The AI will be able to access game state and perform actions!")
if __name__ == "__main__":
asyncio.run(main())