This document describes the MCP (Model Context Protocol) integration added to the Nodeium browser, enabling external AI models to interact with browser functionality through standardized tools and resources.
The MCP integration provides a standardized interface for AI models to control the Nodeium browser, including navigation, interaction with web pages, and management of the built-in AI assistant. This allows external AI systems to programmatically control the browser through a well-defined protocol.
The MCP implementation consists of three main components:
- MCP Server (
mcp-server.js) - Main process component that defines tools and resources - MCP Integration (
mcp-integration.js) - Main process bridge between MCP server and browser functionality - MCP Client (
mcp-client.js) - Renderer process component that handles MCP actions
Navigate to a specific URL.
Parameters:
url(string, required): The URL to navigate to
Example:
{
"url": "https://example.com"
}Search using the default search engine.
Parameters:
query(string, required): The search query
Example:
{
"query": "JavaScript tutorials"
}Perform browser navigation actions.
Parameters:
action(string, required): Navigation action (back,forward,refresh)
Example:
{
"action": "back"
}Interact with web page elements.
Parameters:
action(string, required): Type of interaction (click,type,scroll,find,select,checkbox)target(string, required): Element description or targetvalue(string, optional): Value for type/select actionsdirection(string, optional): Scroll direction (up,down,top,bottom)
Examples:
{
"action": "click",
"target": "Login button"
}{
"action": "type",
"target": "username input",
"value": "myuser123"
}{
"action": "scroll",
"direction": "down"
}Get information about the current browser state.
Parameters:
info_type(string, required): Type of information (current_url,page_title,element_info,browser_state)element_description(string, optional): Element description forelement_info
Examples:
{
"info_type": "current_url"
}{
"info_type": "element_info",
"element_description": "submit button"
}Wait for specific conditions on the page.
Parameters:
condition(string, required): Condition to wait for (element,url_change,page_load)target(string, optional): Target element or URL patterntimeout(number, optional): Timeout in milliseconds (default: 10000)
Example:
{
"condition": "element",
"target": "login form",
"timeout": 5000
}Control the AI assistant functionality.
Parameters:
action(string, required): Action to perform (toggle_sidebar,send_message,clear_chat,get_settings)message(string, optional): Message to send (forsend_messageaction)
Examples:
{
"action": "toggle_sidebar"
}{
"action": "send_message",
"message": "Search for weather information"
}Get current browser state including URL, title, and tab information.
Response:
{
"url": "https://example.com",
"title": "Example Domain",
"tabs": 3,
"activeTab": "Example Domain"
}Browser navigation history (currently placeholder implementation).
AI assistant configuration settings.
Response:
{
"apiKey": "sk-...",
"apiUrl": "https://api.openai.com/v1",
"model": "gpt-3.5-turbo",
"temperature": 0.7,
"maxTokens": 1000,
"contextAware": true
}AI assistant chat history.
Response:
{
"messages": [
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hi there!"}
],
"timestamp": "2025-10-28T06:30:00.000Z"
}// Navigate to a website
await mcp.callTool('browser_navigate', { url: 'https://google.com' });
// Search for content
await mcp.callTool('browser_search', { query: 'Nodeium browser' });// Fill out a login form
await mcp.callTool('browser_interact', {
action: 'type',
target: 'username input',
value: 'myusername'
});
await mcp.callTool('browser_interact', {
action: 'type',
target: 'password input',
value: 'mypassword'
});
await mcp.callTool('browser_interact', {
action: 'click',
target: 'Login button'
});// Get current page information
const state = await mcp.getResource('browser://current-state');
console.log(state.url, state.title);
// Get element information
const info = await mcp.callTool('browser_get_info', {
info_type: 'element_info',
element_description: 'navigation menu'
});// Send a message to the AI assistant
await mcp.callTool('ai_assistant_control', {
action: 'send_message',
message: 'Navigate to Wikipedia and search for artificial intelligence'
});
// Get AI assistant settings
const settings = await mcp.getResource('ai-assistant://settings');The MCP integration leverages the existing browser functionality:
- Navigation: Uses the existing
go(),back(),forward(),refresh()functions - Web Interaction: Uses webview
executeJavaScript()for DOM manipulation - AI Assistant: Integrates with the existing AI assistant sidebar and chat functionality
- Tab Management: Works with the electron-tabs library for multi-tab support
- All MCP operations are subject to the same security restrictions as the browser
- Webview interactions are sandboxed and follow the browser's security policies
- API keys and sensitive information are handled through secure IPC communication
- External MCP clients must be properly authenticated and authorized
To add a new MCP tool:
- Define the tool in
mcp-server.jsin thesetupTools()method - Implement the tool handler in
mcp-integration.jsin thehandleToolExecution()method - Add renderer-side handling in
mcp-client.jsif needed
To add a new MCP resource:
- Define the resource in
mcp-server.jsin thesetupResources()method - Implement the resource handler in
mcp-integration.jsin thehandleResourceFetching()method
The MCP functionality can be tested by:
- Starting the Nodeium browser
- Using the browser's developer tools to call MCP functions:
// Test navigation await window.mcp.callTool('browser_navigate', { url: 'https://example.com' }); // Test information retrieval const state = await window.mcp.getResource('browser://current-state'); console.log(state);
Potential future enhancements include:
- More sophisticated element detection and interaction
- Browser automation workflows
- Session management and persistence
- Integration with browser extensions
- Advanced waiting conditions and timeouts
- Browser performance metrics and analytics
- Tool not found: Ensure the tool name is correctly spelled and defined
- Webview not available: Check that a webview is loaded and active
- IPC communication errors: Verify that preload.js is correctly exposing MCP functions
- Element not found: Use more specific element descriptions or check the page structure
Enable debug logging by checking the browser's developer console for MCP-related messages. The MCP client and server both log initialization and operation details.
This MCP integration is part of the Nodeium browser and follows the same licensing terms as the main project.