Skip to content

Commit c16894c

Browse files
committed
MCP: Add resources (knowledge)
1 parent 512b4a4 commit c16894c

File tree

17 files changed

+2649
-12
lines changed

17 files changed

+2649
-12
lines changed

.github/workflows/geargrafx.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ jobs:
4343
working-directory: platforms/linux
4444
- name: Prepare artifact directory
4545
run: |
46-
mkdir -p artifact
46+
mkdir -p artifact/mcp
4747
cp platforms/shared/README.txt artifact
4848
cp platforms/shared/gamecontrollerdb.txt artifact
4949
cp platforms/linux/${{ env.NAME_LOWER }} artifact
50+
cp -r platforms/shared/desktop/mcp/resources artifact/mcp/
5051
- name: Archive binary
5152
uses: actions/upload-artifact@v4
5253
with:
@@ -194,11 +195,12 @@ jobs:
194195
working-directory: platforms/windows
195196
- name: Prepare artifact directory
196197
run: |
197-
mkdir -p artifact
198+
mkdir -p artifact/mcp
198199
cp platforms/shared/README.txt artifact
199200
cp platforms/shared/gamecontrollerdb.txt artifact
200201
cp platforms/windows/dependencies/SDL2-2.30.6/lib/${{ matrix.architecture }}/SDL2.dll artifact
201202
cp platforms/windows/release/${{ env.NAME_UPPER }}.exe artifact
203+
cp -r platforms/shared/desktop/mcp/resources artifact/mcp/
202204
- name: Archive binary
203205
uses: actions/upload-artifact@v4
204206
with:
@@ -229,10 +231,11 @@ jobs:
229231
gmake
230232
- name: Prepare artifact directory
231233
run: |
232-
mkdir -p artifact
234+
mkdir -p artifact/mcp
233235
cp platforms/shared/README.txt artifact
234236
cp platforms/shared/gamecontrollerdb.txt artifact
235237
cp platforms/bsd/${{ env.NAME_LOWER }} artifact
238+
cp -r platforms/shared/desktop/mcp/resources artifact/mcp/
236239
- name: Archive binary
237240
uses: actions/upload-artifact@v4
238241
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.DS_Store
33
*.dylib
44
*.app/
5+
platforms/macos/mcp
56

67
# Visual Studio files
78
.vscode/mcp.json

MCP_README.md

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This server provides comprehensive tools for game development, rom hacking, reve
1515
- **Bookmarks**: Memory and disassembler bookmarks for navigation
1616
- **Call Stack**: View function call hierarchy
1717
- **Screenshot Capture**: Get current frame as PNG image
18+
- **Documentation Resources**: Built-in hardware and programming documentation for AI context
1819
- **GUI Integration**: MCP server runs alongside the emulator GUI, sharing the same state
1920

2021
## Available MCP Tools
@@ -107,7 +108,7 @@ The default mode uses standard input/output for communication. The emulator is l
107108

108109
### HTTP Transport
109110

110-
The HTTP transport mode runs the emulator with an embedded web server on `localhost:7777`. The emulator stays running independently while the AI client connects via HTTP.
111+
The HTTP transport mode runs the emulator with an embedded web server on `localhost:7777/mcp`. The emulator stays running independently while the AI client connects via HTTP.
111112

112113
**Advantages:**
113114
- Persistent emulator instance
@@ -185,10 +186,11 @@ The HTTP transport mode runs the emulator with an embedded web server on `localh
185186
1. **Start the emulator manually** with HTTP transport:
186187
```bash
187188
./geargrafx --mcp-http
188-
# Server will start on http://localhost:7777
189+
# Server will start on http://localhost:7777/mcp
189190

190191
# Or specify a custom port:
191192
./geargrafx --mcp-http --mcp-http-port 3000
193+
# Server will start on http://localhost:3000/mcp
192194
```
193195

194196
You can optionally start the server using the "MCP" menu in the GUI.
@@ -199,7 +201,7 @@ The HTTP transport mode runs the emulator with an embedded web server on `localh
199201
"servers": {
200202
"geargrafx": {
201203
"type": "http",
202-
"url": "http://localhost:7777",
204+
"url": "http://localhost:7777/mcp",
203205
"headers": {}
204206
}
205207
}
@@ -212,7 +214,7 @@ The HTTP transport mode runs the emulator with an embedded web server on `localh
212214
"github.copilot.chat.mcp.servers": {
213215
"geargrafx": {
214216
"type": "http",
215-
"url": "http://localhost:7777"
217+
"url": "http://localhost:7777/mcp"
216218
}
217219
}
218220
}
@@ -224,7 +226,7 @@ The HTTP transport mode runs the emulator with an embedded web server on `localh
224226
"mcpServers": {
225227
"geargrafx": {
226228
"type": "http",
227-
"url": "http://localhost:7777"
229+
"url": "http://localhost:7777/mcp"
228230
}
229231
}
230232
}
@@ -252,6 +254,74 @@ Once configured, you can ask your AI assistant:
252254
- "Show me the VDC registers"
253255
- "Capture a screenshot of the current frame"
254256

257+
## Available Resources
258+
259+
In addition to tools, the MCP server provides documentation resources that AI assistants can access to better understand the PC Engine / TurboGrafx-16 hardware and programming.
260+
261+
Resources are organized into categories and are automatically loaded when the server starts. They provide context and reference material for AI-assisted debugging and development.
262+
263+
### Hardware Documentation Resources
264+
265+
Complete technical reference documentation for all PC Engine / TurboGrafx-16 hardware components:
266+
267+
- **HuC6280 CPU — 8-bit CMOS Microprocessor** (`geargrafx://hardware/huc6280_cpu`)
268+
- 65C02-compatible core architecture
269+
- CPU registers (A/X/Y/S/P/PC) and status flags
270+
- Memory Management Unit (MMU) with 8×8KB page mapping
271+
- Interrupt controller, 7-bit timer, I/O ports
272+
- Clock speeds (1.79MHz/7.16MHz switchable)
273+
274+
- **HuC6280 Instruction Set Reference** (`geargrafx://hardware/huc6280_instructions`)
275+
- Complete instruction set with all 65C02 base opcodes
276+
- HuC6280 extensions (BBR/BBS/RMB/SMB/TST/TAM/TMA/SAX/SAY/SXY/ST0/ST1/ST2/CSL/CSH/CLA/CLX/CLY/TAI/TDD/TIA/TII/TIN)
277+
- Addressing modes, cycle counts, flags affected
278+
279+
- **HuC6280 PSG — Programmable Sound Generator** (`geargrafx://hardware/huc6280_psg`)
280+
- 6 waveform channels with 32-sample waveform memory
281+
- Dual noise generators (channels 5 and 6)
282+
- Low Frequency Oscillator (LFO)
283+
- Stereo balance control and Direct D/A mode (DDA)
284+
285+
- **HuC6270 VDC — Video Display Controller** (`geargrafx://hardware/huc6270_vdc`)
286+
- 64KB VRAM with internal registers (R00-R13)
287+
- Display timing control and sprite rendering
288+
- Sprite Attribute Table (SAT) and DMA operations
289+
- Dual-VDC SuperGrafx support
290+
291+
- **HuC6260 VCE — Video Color Encoder** (`geargrafx://hardware/huc6260_vce`)
292+
- 512×9-bit color RAM (3-bit R/G/B per entry)
293+
- Palette organization (16 palettes × 16 colors)
294+
- Color table access and analog video output
295+
296+
- **HuC6202 VPC — Video Priority Controller** (`geargrafx://hardware/huc6202_vpc`)
297+
- SuperGrafx dual-VDC (VDC#1/VDC#2) arbitration
298+
- Priority control registers and window-based layer visibility
299+
- Per-pixel priority resolution
300+
301+
- **PC Engine Memory Map** (`geargrafx://hardware/memory_map`)
302+
- 64KB logical / 2MB physical address space
303+
- MMU 8KB page translation (MPR0-MPR7)
304+
- Hardware register layout (VDC/$0000, VCE/$0400, PSG/$0800, Timer/$0C00, Input/$1000, IRQ/$1400)
305+
- RAM configuration, ROM banking, CD-ROM/Arcade Card extensions
306+
307+
### How Resources Work
308+
309+
Resources are read-only documentation that AI assistants can reference during conversations:
310+
311+
1. **Automatic Loading**: Resources are loaded when the MCP server starts
312+
2. **Context Enhancement**: AI assistants can retrieve resources to understand hardware specifics
313+
3. **Format**: Resources are provided in Markdown format for easy reading
314+
4. **URIs**: Each resource has a unique URI like `geargrafx://category/resource_id`
315+
316+
### Accessing Resources
317+
318+
Resources are accessed through the MCP protocol's resource capabilities:
319+
320+
- `resources/list` - List all available resources
321+
- `resources/read` - Read the content of a specific resource
322+
323+
AI clients automatically handle resource retrieval, so you typically don't need to manually request them. The AI assistant will fetch relevant resources when needed to answer your questions or provide better debugging assistance.
324+
255325
## How It Works
256326

257327
- The MCP server runs **alongside** the GUI in a background thread

platforms/macos/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ APP_NAME=Geargrafx
1212
bundle:
1313
rm -rf $(APP_NAME).app
1414
mkdir -p $(APP_NAME).app/Contents/{MacOS,Resources,Frameworks}
15+
mkdir -p $(APP_NAME).app/Contents/MacOS/mcp
1516
sed -e "s/@version@/$(GIT_VERSION)/g" Info.plist > $(APP_NAME).app/Contents/Info.plist
1617
cp iconfile.icns $(APP_NAME).app/Contents/Resources/
1718
cp $(TARGET) $(APP_NAME).app/Contents/MacOS/
1819
cp run.sh $(APP_NAME).app/Contents/MacOS/
1920
cp ../shared/gamecontrollerdb.txt $(APP_NAME).app/Contents/MacOS/
21+
cp -r ../shared/desktop/mcp/resources $(APP_NAME).app/Contents/MacOS/mcp/
2022

2123
dist: clean all bundle
2224
@echo Success!!

0 commit comments

Comments
 (0)