Files
HumanAgent-MCP/src/mcp/extensionBridge.ts
T
B Harper a414a4f70d Fix sessionless HumanAgent chat functionality
- Remove session management complexity from MCP server and UI
- Update chatWebviewProvider for direct messaging without sessions
- Fix MCP tool response format to use content array as per specification
- Restore cog icon for MCP configuration (install global/local)
- Add safety checks for message content handling
- Resolve 'o.content is not iterable' error by using proper MCP format
2025-10-22 11:49:17 +11:00

64 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
/**
* Extension Bridge for MCP
* This script acts as a bridge between VS Code's MCP client and the extension's internal MCP server
* It uses VS Code's extension API to communicate with the running extension
*/
import * as vscode from 'vscode';
class ExtensionBridge {
async start() {
// This script will be executed when VS Code connects to the MCP server
// We need to find a way to communicate with the extension's internal McpServer
// For now, use stdio communication
process.stdin.on('data', async (data) => {
try {
const input = data.toString().trim();
if (!input) {
return;
}
const message = JSON.parse(input);
// Try to get the extension and forward the message
const extension = vscode.extensions.getExtension('your-extension-id');
if (extension && extension.isActive) {
// This won't work because this script runs in a separate process
// We need a different approach
}
// For now, return an error
const errorResponse = {
id: message.id,
type: 'response',
error: {
code: -32603,
message: 'Extension bridge not implemented yet'
}
};
process.stdout.write(JSON.stringify(errorResponse) + '\n');
} catch (error) {
const errorResponse = {
id: null,
type: 'response',
error: {
code: -32700,
message: 'Parse error',
data: error instanceof Error ? error.message : String(error)
}
};
process.stdout.write(JSON.stringify(errorResponse) + '\n');
}
});
}
}
// Start the bridge
const bridge = new ExtensionBridge();
bridge.start().catch((error) => {
console.error('Failed to start extension bridge:', error);
process.exit(1);
});