Skip to content

Commit 3a110f7

Browse files
committed
x
1 parent e3f0aca commit 3a110f7

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

main/chat-engine.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,15 @@ async function executeTool(toolName, toolInput, projectPath, webContents) {
14031403
if (result?.content && Array.isArray(result.content)) {
14041404
// Check for error responses
14051405
if (result.isError) {
1406+
const structuredError = result.structuredContent?.error;
1407+
if (structuredError && typeof structuredError === 'object') {
1408+
return {
1409+
error: structuredError.message || result.structuredContent.message || 'Tool returned an error',
1410+
code: structuredError.code || result.structuredContent.code,
1411+
hint: structuredError.hint || result.structuredContent.hint,
1412+
details: structuredError.details || result.structuredContent.details
1413+
};
1414+
}
14061415
const text = result.content.map(c => c.text || '').join('');
14071416
return { error: text || 'Tool returned an error' };
14081417
}

main/mcp-client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { spawn } from 'child_process';
22
import { app } from 'electron';
3+
import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/sdk/types.js';
34
import { getProjectCLISpawnArgs, getChildEnv, killProcessTree } from './node-env.js';
45
import { getPreviewPort } from './preview-manager.js';
56
import { createLogger } from './logger.js';
@@ -172,7 +173,7 @@ class McpConnection {
172173

173174
this.initPromise = (async () => {
174175
const result = await this.request('initialize', {
175-
protocolVersion: '2024-11-05',
176+
protocolVersion: LATEST_PROTOCOL_VERSION,
176177
capabilities: {},
177178
clientInfo: { name: 'coursecode-desktop', version: app.getVersion() }
178179
});

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@
4343
"dependencies": {
4444
"@anthropic-ai/sdk": "^0.91.1",
4545
"@electron-toolkit/utils": "^4.0.0",
46+
"@modelcontextprotocol/sdk": "^1.29.0",
4647
"@tiptap/core": "^3.22.4",
4748
"@tiptap/markdown": "^3.22.4",
4849
"@tiptap/starter-kit": "^3.22.4",
49-
"coursecode": "^0.1.43",
50+
"coursecode": "^0.1.46",
5051
"electron-updater": "^6.3.9",
5152
"isomorphic-git": "^1.37.6",
5253
"marked": "^18.0.2",

spec.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ A standalone Electron app that gives instructional designers a native GUI for Co
7373
- GitHub Release artifact names must match the website download metadata naming convention (`CourseCode-Desktop-v<version>-mac.dmg`, `CourseCode-Desktop-v<version>-win.exe`)
7474
- Runtime version reporting rules:
7575
- App UI "About" and update checks must use Electron `app.getVersion()`
76-
- MCP client handshake version must use the app runtime version, not a hardcoded string
76+
- MCP client metadata must send Electron `app.getVersion()` as the Desktop runtime version
77+
- MCP protocol negotiation must use the SDK's current `LATEST_PROTOCOL_VERSION`, not a hardcoded protocol date
7778
- Changelogs should distinguish:
7879
- Desktop app changes (open source)
7980
- Framework/CLI changes (open source)
@@ -823,7 +824,7 @@ Defined in `ai-config.js` as `FILE_TOOL_DEFINITIONS`. These execute locally via
823824

824825
#### MCP Tools (framework-provided)
825826

826-
Discovered at runtime from the CourseCode framework's MCP server via stdio JSON-RPC (`coursecode mcp --port <port>`). The MCP connection is managed by `mcp-client.js`. The desktop app assumes the MCP server is **always available** when a preview is running; MCP tools are only included in the tool list when a preview server is active.
827+
Discovered at runtime from the CourseCode framework's MCP server via stdio JSON-RPC (`coursecode mcp --port <port>`). The MCP connection is managed by `mcp-client.js`. The desktop app assumes the MCP server is **always available** when a preview is running; MCP tools are only included in the tool list when a preview server is active. Desktop depends directly on `@modelcontextprotocol/sdk` so the client can negotiate with the SDK's current `LATEST_PROTOCOL_VERSION` while still sending the Electron app version as client metadata. Framework MCP tools return `structuredContent` for machine-readable results while keeping text content for compatibility. When MCP tools fail, Desktop preserves structured fields such as `code`, `hint`, and `details` so the AI can recover from tool errors without parsing prose.
827828

828829
| Tool | Purpose |
829830
|---|---|

0 commit comments

Comments
 (0)