Skip to main content
Glama

ref_read_url

Extracts and converts webpage content into markdown format using a provided URL. Ideal for processing documentation links from 'ref_search_documentation' results for easy reading and integration.

Instructions

Read the content of a url as markdown. The entire exact URL from a Ref 'ref_search_documentation' result should be passed to this tool to read it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL of the webpage to read.

Implementation Reference

  • The `doRead` function implements the core logic of the `ref_read_url` tool. It fetches the content of the provided URL from the Ref API, converts it to markdown, handles client-specific response formats (OpenAI DeepResearch vs standard), manages authentication, and gracefully handles errors including 401 unauthorized.
    async function doRead(url: string, mcpClient: string = 'unknown', sessionId?: string) {
      try {
        const readUrl = getRefUrl() + '/read?url=' + encodeURIComponent(url)
        console.error('[read]', readUrl)
    
        if (!getApiKey()) {
          return {
            content: [
              {
                type: 'text',
                text: 'Ref is not correctly configured. Reach out to hello@ref.tools for help.',
              },
            ],
          }
        }
    
        const response = await axios.get(readUrl, {
          headers: getAuthHeaders(sessionId),
        })
    
        const data = response.data
    
        // Return different formats based on client type
        if (mcpClient === 'openai-mcp') {
          const result: DeepResearchShape = {
            id: url,
            title: data.title || '',
            text: data.content || '',
            url,
          }
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result),
              },
            ],
          }
        } else {
          return {
            content: [{ type: 'text', text: data.content || '' }],
          }
        }
      } catch (error) {
        if (axios.isAxiosError(error) && error.response?.status === 401) {
          return {
            content: [
              {
                type: 'text',
                text: 'Please verify your email at https://ref.tools/dashboard to read URLs',
              },
            ],
          }
        }
    
        console.error('[read-error]', error)
        return {
          content: [
            {
              type: 'text',
              text: `Error reading URL: ${axios.isAxiosError(error) ? error.message : (error as Error).message}`,
            },
          ],
        }
      }
    }
  • Defines the schema for the `ref_read_url` tool, including name (`ref_read_url` via config), description, input schema requiring a `url` string, and `readOnlyHint` annotation.
    const readTool: Tool = {
      name: toolConfig.readToolName,
      description: `Read the content of a url as markdown. The EXACT url from a '${toolConfig.searchToolName}' result should be passed to this tool.`,
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The URL of the webpage to read.',
          },
        },
        required: ['url'],
      },
      annotations: {
        readOnlyHint: true,
      },
    }
  • index.ts:119-121 (registration)
    Registers the `ref_read_url` tool (as `readTool`) in the MCP `listTools` response, making it discoverable to clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [searchTool, readTool],
    }))
  • index.ts:206-209 (registration)
    Dispatches `callTool` requests for `ref_read_url` (matching `toolConfig.readToolName`) to the `doRead` handler function within the MCP `callTool` request handler.
    if (request.params.name === toolConfig.readToolName) {
      const input = request.params.arguments as { url: string }
      return doRead(input.url, mcpClient, sessionId)
    }
  • index.ts:34-37 (registration)
    Configures the tool name `ref_read_url` for the default (non-OpenAI) client setup, used in tool definitions and dispatch logic.
    const DEFAULT_TOOL_CONFIG: ToolConfig = {
      searchToolName: 'ref_search_documentation',
      readToolName: 'ref_read_url',
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool reads content and converts it to markdown, but lacks details on error handling, rate limits, authentication needs, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is highly concise and well-structured in two sentences. The first sentence states the core purpose, and the second provides usage context. There is no wasted language, making it front-loaded and efficient.

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

Completeness3/5

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

Given the tool's moderate complexity (reading and converting web content) and lack of annotations or output schema, the description is adequate but incomplete. It covers purpose and basic usage but omits behavioral details like error cases or output specifics, leaving room for improvement in completeness.

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

Parameters3/5

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

The input schema has 100% description coverage, with the parameter 'url' documented as 'The URL of the webpage to read.' The description adds minimal value beyond this by specifying that the URL should come from 'ref_search_documentation' results, but does not provide additional syntax or format details. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Read the content of a url as markdown.' It specifies the verb ('Read') and resource ('content of a url'), making the action explicit. However, it does not explicitly distinguish this tool from its sibling 'ref_search_documentation', which likely searches rather than reads content, so it misses full differentiation.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: 'The entire exact URL from a Ref 'ref_search_documentation' result should be passed to this tool to read it.' This implies usage after obtaining a URL from the sibling tool, offering a workflow guideline. However, it does not specify when not to use it or alternatives, keeping it from a perfect score.

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

Related 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/ref-tools/ref-tools-mcp'

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