Skip to content

Commit f5711ce

Browse files
committed
docs: update architecture and development docs with MCP resources system
- Update TOOLS.md: correct tool count from 84 to 105+, add MCP Resources section - Update ARCHITECTURE.md: add MCP Resources Layer to architecture diagram, detailed resource system documentation - Update PLUGIN_DEVELOPMENT.md: comprehensive guide for creating MCP resources, testing patterns, auto-discovery - Document client capability detection, smart tool filtering, and resource implementation patterns - Update plugin categories count and structure references - Provide complete development workflow for both tools and resources
1 parent 8407273 commit f5711ce

3 files changed

Lines changed: 162 additions & 6 deletions

File tree

docs/ARCHITECTURE.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ XcodeBuildMCP is a Model Context Protocol (MCP) server that exposes Xcode operat
4242
│ • plugins/**/ – self-contained plugins │
4343
└────────────────────────────────────────────────────────────┘
4444
┌────────────────────────────────────────────────────────────┐
45+
│ MCP Resources Layer │
46+
│ • src/core/resources.ts – resource management │
47+
│ • src/resources/**/ – MCP resource handlers │
48+
│ • Client capability detection – automatic tool filtering │
49+
└────────────────────────────────────────────────────────────┘
50+
┌────────────────────────────────────────────────────────────┐
4551
│ Plugin Implementation Layer │
4652
│ • plugins/**/**.js – one file per tool capability │
4753
│ • Common patterns: │
@@ -229,6 +235,56 @@ plugins/
229235
└── discovery/ # Dynamic tool discovery
230236
```
231237

238+
### MCP Resources System
239+
240+
XcodeBuildMCP provides dual interfaces: traditional MCP tools and efficient MCP resources for supported clients.
241+
242+
#### Resource Architecture
243+
244+
```
245+
src/resources/
246+
├── simulators.ts # Simulator data resource
247+
└── __tests__/ # Resource-specific tests
248+
```
249+
250+
#### Client Capability Detection
251+
252+
The system automatically detects client MCP capabilities:
253+
254+
```typescript
255+
// src/core/resources.ts
256+
export function supportsResources(server?: unknown): boolean {
257+
// Detects client capabilities via getClientCapabilities()
258+
// Conservative fallback: assumes resource support
259+
}
260+
```
261+
262+
#### Smart Tool Filtering
263+
264+
When resources are available, redundant tools are automatically filtered:
265+
266+
- **Resource-supported clients**: Get `mcp://xcodebuild/simulators` resource
267+
- **Tool-only clients**: Keep `list_sims` tool for compatibility
268+
- **Automatic detection**: No client configuration required
269+
270+
#### Resource Implementation Pattern
271+
272+
Resources reuse existing tool logic for consistency:
273+
274+
```typescript
275+
// src/resources/simulators.ts
276+
export default {
277+
uri: 'mcp://xcodebuild/simulators',
278+
description: 'Available iOS simulators with UUIDs and states',
279+
mimeType: 'text/plain',
280+
async handler(executor = getDefaultCommandExecutor()) {
281+
// Reuses list_simsLogic for consistency
282+
const result = await list_simsLogic({}, executor);
283+
return { contents: [{ type: 'text', text: result.content[0].text }] };
284+
}
285+
};
286+
```
287+
232288
### Utility Layer
233289

234290
#### Command Execution (`src/utils/command.ts`)
@@ -257,7 +313,7 @@ plugins/
257313

258314
## Plugin Organization
259315

260-
### Plugin Categories (84 tools total across 16 directories)
316+
### Plugin Categories (105+ tools total across 15 workflow directories)
261317

262318
#### Build Tools (20 tools)
263319
- macOS builds (workspace/project)

docs/PLUGIN_DEVELOPMENT.md

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ This guide provides comprehensive instructions for creating new tools and workfl
88
2. [Plugin Architecture](#plugin-architecture)
99
3. [Creating New Tools](#creating-new-tools)
1010
4. [Creating New Workflow Groups](#creating-new-workflow-groups)
11-
5. [Auto-Discovery System](#auto-discovery-system)
12-
6. [Testing Guidelines](#testing-guidelines)
13-
7. [Development Workflow](#development-workflow)
14-
8. [Best Practices](#best-practices)
11+
5. [Creating MCP Resources](#creating-mcp-resources)
12+
6. [Auto-Discovery System](#auto-discovery-system)
13+
7. [Testing Guidelines](#testing-guidelines)
14+
8. [Development Workflow](#development-workflow)
15+
9. [Best Practices](#best-practices)
1516

1617
## Overview
1718

@@ -304,6 +305,95 @@ export { default } from '../simulator-shared/boot_sim.js';
304305
3. Each tool maintains project or workspace specificity
305306
4. Implementation shared, interfaces remain unique
306307

308+
## Creating MCP Resources
309+
310+
MCP Resources provide efficient URI-based data access for clients that support the MCP resource specification (VS Code, Claude Code, Claude Desktop).
311+
312+
### 1. Resource Structure
313+
314+
Resources are located in `src/resources/` and follow this pattern:
315+
316+
```typescript
317+
// src/resources/example.ts
318+
export default {
319+
uri: 'mcp://xcodebuild/example',
320+
description: 'Description of the resource data',
321+
mimeType: 'text/plain',
322+
async handler(executor: CommandExecutor = getDefaultCommandExecutor()) {
323+
// Resource implementation
324+
return {
325+
contents: [{ type: 'text', text: 'resource data' }]
326+
};
327+
}
328+
};
329+
```
330+
331+
### 2. Resource Implementation Guidelines
332+
333+
**Reuse Existing Logic**: Resources should reuse existing tool logic for consistency:
334+
335+
```typescript
336+
// src/resources/simulators.ts
337+
import { list_simsLogic } from '../plugins/simulator-shared/list_sims.js';
338+
339+
export default {
340+
uri: 'mcp://xcodebuild/simulators',
341+
description: 'Available iOS simulators with UUIDs and states',
342+
mimeType: 'text/plain',
343+
async handler(executor = getDefaultCommandExecutor()) {
344+
const result = await list_simsLogic({}, executor);
345+
return {
346+
contents: [{ type: 'text', text: result.content[0].text }]
347+
};
348+
}
349+
};
350+
```
351+
352+
### 3. Tool Redundancy Management
353+
354+
When creating resources, update the redundancy filter:
355+
356+
```typescript
357+
// src/core/resources.ts
358+
export function getRedundantToolNames(): string[] {
359+
return [
360+
'list_sims', // Redundant with simulators resource
361+
'your_new_tool', // Add new redundant tools here
362+
];
363+
}
364+
```
365+
366+
### 4. Resource Testing
367+
368+
Create tests in `src/resources/__tests__/`:
369+
370+
```typescript
371+
// src/resources/__tests__/example.test.ts
372+
import exampleResource from '../example.js';
373+
import { createMockExecutor } from '../../utils/test-common.js';
374+
375+
describe('example resource', () => {
376+
it('should return resource data', async () => {
377+
const mockExecutor = createMockExecutor({
378+
success: true,
379+
output: 'test data'
380+
});
381+
382+
const result = await exampleResource.handler(mockExecutor);
383+
384+
expect(result.contents[0].text).toContain('expected data');
385+
});
386+
});
387+
```
388+
389+
### 5. Auto-Discovery
390+
391+
Resources are automatically discovered and loaded by the build system. After creating a resource:
392+
393+
1. Run `npm run build` to regenerate resource loaders
394+
2. The resource will be available at its URI for supported clients
395+
3. Redundant tools will be automatically filtered for resource-capable clients
396+
307397
## Auto-Discovery System
308398

309399
### How Auto-Discovery Works

docs/TOOLS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# XcodeBuildMCP Tools Reference
22

3-
This document provides a comprehensive list of all 84 tools available in XcodeBuildMCP, organized by functionality.
3+
This document provides a comprehensive list of all 105+ tools available in XcodeBuildMCP, organized by functionality.
4+
5+
## MCP Resources
6+
7+
For clients that support MCP resources (VS Code, Claude Code, Claude Desktop), XcodeBuildMCP also provides efficient URI-based data access:
8+
9+
| Resource URI | Description | Replaces Tool |
10+
|--------------|-------------|---------------|
11+
| `mcp://xcodebuild/simulators` | Available iOS simulators with UUIDs and states | `list_sims` |
12+
13+
**Note**: Resources provide the same data as their corresponding tools but through efficient URI access. XcodeBuildMCP automatically detects client capabilities and filters out redundant tools when resources are available.
414

515
## Tool Categories
616

0 commit comments

Comments
 (0)