Skip to content

Implement Browser Tabs as MCP Resources #156

Open
@HikaruEgashira

Description

@HikaruEgashira

Overview

Currently, in our MCP implementation, page content is returned as tool output after browser operations (tools) are executed. This causes the same content to be repeatedly included in the context, leading to context capacity issues. To resolve this, we propose implementing browser tabs using the MCP "resources" protocol and notifying changes only when snapshots are modified.

Background

MCP has two main protocols:

  • Tools: Interface for models to execute operations (action execution)
  • Resources: Mechanism to publish data and content from the server (data reference)

Browser tab state should be treated as data, making the resources protocol more appropriate for management.

Objective

  • Implement browser tabs as resources
  • Efficiently manage snapshot changes to reduce context usage
  • Establish coordination between tools and resources

Implementation Details

1. Resource Definition

// Tab resource URI schema: tab://{tabId}/snapshot

2. Resource Management Class Implementation

  • Create a class to represent tabs as resources
  • Implement a resource update notification mechanism
  • Implement a reference function using tab IDs

3. Tool and Resource Integration

  • Implement resource update processing after browser operation tool execution
  • Add a mechanism to notify only when changes occur

4. Client Notification System

  • Implement change notifications using the Resource Updates protocol
  • Efficient resource management on the client side

Technical Details

Resource Management

// Resources will have the following interface
interface TabResource {
  uri: string; // Example: tab://1/snapshot
  content: string; // Accessibility snapshot content
  contentType: string; // Example: "text/html" or "application/json"
  metadata: {
    title: string;
    url: string;
    lastUpdated: string;
  }
}

Change Detection and Notification

  • Implementation of snapshot diff detection algorithm
  • Filtering mechanism to notify only significant changes

Expected Benefits

  1. Reduced context usage
  2. Improved interaction efficiency with AI models
  3. Ability to retain more useful information within context

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions