Skip to content

Commit d98032c

Browse files
committed
Create CLAUDE.md
1 parent 7fe49c6 commit d98032c

File tree

1 file changed

+206
-0
lines changed

1 file changed

+206
-0
lines changed

CLAUDE.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Cheat Engine MCP (Model Context Protocol) Server that provides REST API access to Cheat Engine functionality through a C# plugin and Python MCP client. The project enables AI tools to interact with Cheat Engine for memory analysis, process manipulation, and debugging tasks.
8+
9+
## Build Commands
10+
11+
### C# Plugin
12+
13+
```bash
14+
# Build the plugin
15+
dotnet build
16+
17+
# Build in Release mode
18+
dotnet build -c Release
19+
```
20+
21+
### Python MCP Client
22+
23+
```bash
24+
# Navigate to the client directory
25+
cd ce-mcp-client
26+
27+
# If it doesn't exist you will need to git clone https://github.com/hedgehogform/ce-mcp-client.git inside root folder.
28+
29+
# Install dependencies using UV package manager
30+
uv sync
31+
```
32+
33+
## Architecture
34+
35+
### Core Components
36+
37+
- **Plugin.cs**: Main Cheat Engine plugin entry point that implements `CESDKPluginClass`
38+
39+
- Manages MCP server lifecycle (start/stop)
40+
- Registers Lua functions for CE integration
41+
- Provides configuration UI through WPF window
42+
43+
- **McpServer.cs**: OWIN-based web server that hosts the REST API
44+
45+
- Uses Web API with Swagger documentation
46+
- Configurable host/port via environment variables or config file
47+
48+
- **CheatEngineController.cs**: Main API controller with endpoints for:
49+
50+
- Lua execution
51+
- Process management
52+
- Memory reading/writing
53+
- AOB scanning
54+
- Disassembly
55+
- Memory scanning
56+
57+
- **CheatEngineTools.cs**: Service layer that delegates to specialized tools in `/Tools` directory
58+
59+
### SDK Layer (`/SDK`)
60+
61+
Wrapper classes around Cheat Engine SDK functionality:
62+
63+
- **CESDKLua.cs**: Lua script execution
64+
- **MemoryRead.cs/MemoryWrite.cs**: Memory operations
65+
- **Process.cs**: Process management
66+
- **AOB.cs**: Array of Bytes scanning
67+
- **Disassembler.cs**: Assembly instruction analysis
68+
- **MemScan.cs**: Memory value scanning
69+
70+
### Configuration
71+
72+
- **ServerConfig.cs**: Manages server configuration with defaults:
73+
- Host: 127.0.0.1
74+
- Port: 6300
75+
- Configuration file: `%APPDATA%\CeMCP\config.json`
76+
- Environment variable overrides: `MCP_HOST`, `MCP_PORT`
77+
78+
### Python MCP Client
79+
80+
- **cheat_engine_mcp_server.py**: FastMCP-based server that exposes tools for AI interaction
81+
- Provides async wrappers for all REST API endpoints
82+
- Uses httpx for HTTP communication with configurable timeout (600s)
83+
84+
## Development Workflow
85+
86+
1. Build the C# plugin with `dotnet build`
87+
2. Copy `ce-mcp.dll` from `bin/` to Cheat Engine plugins directory
88+
3. Enable the plugin in Cheat Engine
89+
4. Use "MCP" menu to start/configure the server
90+
5. Test endpoints at `http://localhost:6300/swagger`
91+
92+
## Adding New Tools
93+
94+
To add a new tool/endpoint to the MCP server:
95+
96+
**Important**: Always examine existing implementations first. Look at similar tools in `/Tools`, models in `/Models`, and SDK wrappers in `/SDK` to understand patterns and conventions.
97+
98+
### 1. Create SDK Wrapper (if needed)
99+
If your tool requires new Cheat Engine functionality not already wrapped, create an SDK wrapper in `/SDK` directory (e.g., `NewSDKFeature.cs`):
100+
```csharp
101+
public class NewSDKFeature : CEObjectWrapper
102+
{
103+
public string DoCheatEngineOperation(string parameter)
104+
{
105+
// Use sdk.lua or other CE SDK calls
106+
return sdk.lua.DoString($"return someOperation('{parameter}')");
107+
}
108+
}
109+
```
110+
111+
### 2. Create the Tool Implementation
112+
Add a new tool class in `/Tools` directory (e.g., `NewFeatureTool.cs`):
113+
```csharp
114+
public class NewFeatureTool
115+
{
116+
private readonly NewSDKFeature _sdkFeature = new NewSDKFeature();
117+
118+
public NewFeatureResponse DoSomething(NewFeatureRequest request)
119+
{
120+
try
121+
{
122+
var result = _sdkFeature.DoCheatEngineOperation(request.Parameter);
123+
return new NewFeatureResponse { Success = true, Result = result };
124+
}
125+
catch (Exception ex)
126+
{
127+
return new NewFeatureResponse { Success = false, ErrorMessage = ex.Message };
128+
}
129+
}
130+
}
131+
```
132+
133+
### 3. Add Models
134+
Create request/response models in `/Models` directory:
135+
```csharp
136+
public class NewFeatureRequest
137+
{
138+
public string Parameter { get; set; }
139+
}
140+
141+
public class NewFeatureResponse : BaseResponse
142+
{
143+
public string Result { get; set; }
144+
}
145+
```
146+
147+
### 4. Register in CheatEngineTools
148+
Add the tool to `CheatEngineTools.cs`:
149+
```csharp
150+
private readonly NewFeatureTool _newFeatureTool = new NewFeatureTool();
151+
152+
public NewFeatureResponse DoSomething(NewFeatureRequest request)
153+
{
154+
return _newFeatureTool.DoSomething(request);
155+
}
156+
```
157+
158+
### 5. Add Controller Endpoint
159+
Add endpoint to `CheatEngineController.cs`:
160+
```csharp
161+
[HttpPost]
162+
[Route("new-feature")]
163+
public NewFeatureResponse DoSomething([FromBody] NewFeatureRequest request)
164+
{
165+
return tools.DoSomething(request);
166+
}
167+
```
168+
169+
### 6. Add Python MCP Tool
170+
Add corresponding tool in `ce-mcp-client/src/cheat_engine_mcp_server.py`:
171+
```python
172+
@mcp.tool()
173+
async def do_something(parameter: str) -> Dict[str, Any]:
174+
"""
175+
Description of what this tool does
176+
177+
Args:
178+
parameter: Description of the parameter
179+
180+
Returns:
181+
Dictionary with result and success status
182+
"""
183+
return await make_request("new-feature", "POST", {"Parameter": parameter})
184+
```
185+
186+
## Project Structure
187+
188+
```
189+
├── SDK/ # Cheat Engine SDK wrappers
190+
├── Tools/ # Specialized functionality tools
191+
├── Controllers/ # Web API controllers
192+
├── Models/ # Data transfer objects
193+
├── ce-mcp-client/ # Python MCP client
194+
│ └── src/cheat_engine_mcp_server.py
195+
└── Plugin.cs # Main plugin entry point
196+
```
197+
198+
## Configuration
199+
200+
The server supports configuration through:
201+
202+
1. Environment variables (`MCP_HOST`, `MCP_PORT`)
203+
2. Configuration file at `%APPDATA%\CeMCP\config.json`
204+
3. Runtime configuration through WPF configuration window
205+
206+
Default server runs on `http://127.0.0.1:6300` with Swagger UI available for API testing.

0 commit comments

Comments
 (0)