Skip to main content
Glama
alohays

openai-tool2mcp

by alohays

browser

Access and interact with web content to retrieve information, navigate websites, and perform online tasks through the MCP server.

Instructions

Browse websites and interact with web content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parametersYes

Implementation Reference

  • BrowserAdapter implements the core logic for the 'browser' tool: defines tool_id 'browser', maps to OpenAI 'web_browser', translates MCP requests (url, action) to OpenAI params and responses back to MCP format with markdown.
    class BrowserAdapter(ToolAdapter):
        """Adapter for OpenAI's web browser tool"""
    
        @property
        def tool_id(self) -> str:
            """Get the MCP tool ID"""
            return "browser"
    
        @property
        def openai_tool_type(self) -> str:
            """Get the OpenAI tool type"""
            return "web_browser"
    
        @property
        def description(self) -> str:
            """Get the tool description"""
            return "Browse websites and interact with web content"
    
        async def translate_request(self, request: MCPRequest) -> dict:
            """
            Translate MCP request to OpenAI parameters
    
            Args:
                request: The MCP request to translate
    
            Returns:
                Dictionary of OpenAI parameters
            """
            # Extract URL and action
            url = request.parameters.get("url", "")
            action = request.parameters.get("action", "browse")
    
            logger.debug(f"Translating browser request for URL: {url}, action: {action}")
    
            # Return OpenAI parameters
            return {"url": url, "action": action}
    
        async def translate_response(self, response: dict) -> MCPResponse:
            """
            Translate OpenAI response to MCP response
    
            Args:
                response: The OpenAI response to translate
    
            Returns:
                MCP response object
            """
            # Extract content
            content = response.get("content", "")
            title = response.get("title", "")
            url = response.get("url", "")
    
            logger.debug(f"Translating browser response for URL: {url}")
    
            # Format content as markdown
            formatted_content = f"# {title}\n\n{content}" if title else content
    
            # Check for errors
            error = response.get("error")
    
            # Return MCP response
            return MCPResponse(content=formatted_content, error=error, context={"url": url, "title": title})
  • ToolRegistry._register_default_tools() registers 'browser' tool with mapping to OpenAI WEB_BROWSER, enabled status, and description.
    "browser": {
        "openai_tool": OpenAIBuiltInTools.WEB_BROWSER.value,
        "enabled": OpenAIBuiltInTools.WEB_BROWSER.value in self.enabled_tools,
        "description": "Browse websites and access web content",
    },
  • MCPServer._build_tools_map() instantiates BrowserAdapter and adds it to self.tools_map[adapter.tool_id] ('browser') if enabled in config.
    adapters = [WebSearchAdapter(), CodeInterpreterAdapter(), BrowserAdapter(), FileManagerAdapter()]
    
    for adapter in adapters:
        # Only register if the tool is enabled
        if adapter.openai_tool_type in self.config.tools:
            tools_map[adapter.tool_id] = adapter
  • MCPServer._register_mcp_tools() dynamically creates and registers the MCP tool handler for each adapter (including 'browser'), using @mcp.tool(name=tool_id), which invokes OpenAI via the adapter's translate methods.
    def create_tool_handler(tool_id=tool_id, adapter=adapter):
        @self.mcp.tool(name=tool_id, description=adapter.description)
        async def tool_handler(**parameters):
            """
            MCP tool handler for OpenAI tools.
            """
            # Create an MCP request from the parameters
            mcp_request = MCPRequest(parameters=parameters)
    
            # Translate the request parameters using the adapter
            translated_params = await adapter.translate_request(mcp_request)
    
            # Create an OpenAI tool request
            openai_request = mcp_to_openai.translate_request(mcp_request, tool_id)
    
            # Override the parameters with the adapter-specific ones
            openai_request.parameters = translated_params
    
            try:
                # Call OpenAI API to execute the tool
                openai_response = await self.openai_client.invoke_tool(openai_request)
    
                # Translate the OpenAI response to MCP format using the adapter
                if openai_response.tool_outputs:
                    # Use the adapter to translate the tool-specific response
                    mcp_response = await adapter.translate_response(openai_response.tool_outputs[0].output)
    
                    # Add thread_id to context for state management
                    if mcp_response.context is None:
                        mcp_response.context = {}
                    mcp_response.context["thread_id"] = openai_response.thread_id
    
                    # Return the response content which will be used by MCP SDK
                    return mcp_response.content
                else:
                    # Fallback to generic translation
                    mcp_response = openai_to_mcp.translate_response(openai_response)
                    return mcp_response.content
            except Exception as e:
                logger.error(f"Error invoking tool {tool_id}: {e!s}")
                # Using custom exception class to fix TRY003
                raise ToolInvocationError() from e
    
        return tool_handler
    
    # Create and register the tool handler
    create_tool_handler()
  • Constants defining tool names: BROWSER='browser' and WEB_BROWSER='web_browser' used in registry.
    BROWSER = "browser"
    CODE = "code"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'browse' and 'interact' but doesn't specify whether this is read-only or allows mutations, what permissions or authentication might be needed, rate limits, or what 'interact' entails (e.g., clicking, form submission). It lacks critical behavioral details for a tool with web interaction capabilities.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two short phrases: 'Browse websites' and 'interact with web content'. It's front-loaded with the core purpose, though it could be more structured. There's no wasted text, but it's under-specified rather than efficiently detailed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of web browsing/interaction, no annotations, no output schema, and 0% schema coverage for the single parameter, the description is incomplete. It doesn't cover what the tool returns, how errors are handled, or the scope of interactions. For a tool with potential side effects and rich functionality, this is inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter with 0% description coverage, and the description provides no information about parameters. It doesn't explain what 'parameters' should contain (e.g., URLs, actions, content), their format, or how they're used. For a single undocumented parameter, the description fails to add any semantic value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Browse websites and interact with web content' states a general purpose but lacks specificity. It mentions 'browse' and 'interact' as verbs with 'websites' and 'web content' as resources, but doesn't distinguish from sibling tools like 'web-search' or specify what type of interaction is possible. It's vague about scope and functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'web-search' or other siblings. The description implies a general web browsing context but doesn't specify use cases, prerequisites, or exclusions. There's no mention of when-not-to-use or comparisons to other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alohays/openai-tool2mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server