MCP Integration
Model Context Protocol (MCP)
Section titled “Model Context Protocol (MCP)”CodecFlow uses the Model Context Protocol (MCP) to connect AI agents to cloud desktops, providing a standardized way for models to interact with operating systems and applications.
What is MCP?
Section titled “What is MCP?”MCP (Model Context Protocol) is a standardized protocol that enables AI models to:
- Access contextual information from the environment
- Execute actions in the operating system
- Maintain state across interactions
- Securely communicate with external systems
Basic MCP Agent Setup
Section titled “Basic MCP Agent Setup”const agent = await desktop.connectAgent({ model: 'gpt-4', protocol: 'mcp', config: { capabilities: ['browser', 'filesystem', 'applications'], securityLevel: 'restricted', contextWindow: 'large' }});
MCP Capabilities
Section titled “MCP Capabilities”Pre-built capability sets to get you started:
browser
: Web browsing and interactionfilesystem
: File operations and managementapplications
: Desktop application controlnetwork
: Network operations and API accesssystem
: System-level operationscustom
: Build your own capability set
// Example: Using specific MCP capabilitiesconst automationAgent = await desktop.connectAgent({ model: 'gpt-4', protocol: 'mcp', config: { capabilities: ['filesystem', 'applications'], contextProviders: ['document-context', 'system-state'], memorySize: '16k' }});
MCP Context Providers
Section titled “MCP Context Providers”MCP allows agents to access different types of context:
// Configure context providersconst agent = await desktop.connectAgent({ model: 'gpt-4', protocol: 'mcp', contextProviders: [ { type: 'filesystem', path: '/documents', recursive: true }, { type: 'application', name: 'excel', dataTypes: ['cells', 'formulas', 'charts'] }, { type: 'browser', contentTypes: ['text', 'links', 'forms'] } ]});
// Access context during executionconst context = await agent.getContext('filesystem', '/documents/report.docx');console.log(context.content);
MCP Action Execution
Section titled “MCP Action Execution”Define how your AI agent interacts with the desktop:
// Execute actions through MCPawait agent.executeAction({ type: 'application', application: 'excel', action: 'modifyCell', params: { sheet: 'Sheet1', cell: 'B2', value: '=SUM(A1:A10)' }});
// Handle eventsagent.on('applicationEvent', async (event) => { // Handle application events if (event.type === 'dialogOpened') { await agent.executeAction({ type: 'application', action: 'clickButton', params: { text: 'OK' } }); }});