Skip to content

MCP Integration

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.

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
const agent = await desktop.connectAgent({
model: 'gpt-4',
protocol: 'mcp',
config: {
capabilities: ['browser', 'filesystem', 'applications'],
securityLevel: 'restricted',
contextWindow: 'large'
}
});

Pre-built capability sets to get you started:

  • browser: Web browsing and interaction
  • filesystem: File operations and management
  • applications: Desktop application control
  • network: Network operations and API access
  • system: System-level operations
  • custom: Build your own capability set
// Example: Using specific MCP capabilities
const automationAgent = await desktop.connectAgent({
model: 'gpt-4',
protocol: 'mcp',
config: {
capabilities: ['filesystem', 'applications'],
contextProviders: ['document-context', 'system-state'],
memorySize: '16k'
}
});

MCP allows agents to access different types of context:

// Configure context providers
const 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 execution
const context = await agent.getContext('filesystem', '/documents/report.docx');
console.log(context.content);

Define how your AI agent interacts with the desktop:

// Execute actions through MCP
await agent.executeAction({
type: 'application',
application: 'excel',
action: 'modifyCell',
params: {
sheet: 'Sheet1',
cell: 'B2',
value: '=SUM(A1:A10)'
}
});
// Handle events
agent.on('applicationEvent', async (event) => {
// Handle application events
if (event.type === 'dialogOpened') {
await agent.executeAction({
type: 'application',
action: 'clickButton',
params: { text: 'OK' }
});
}
});