Skip to main content
Glama
rayss868

Web-curl MCP Server

smart_command

Execute web commands by automatically fetching content from detected links or searching for detected queries to retrieve information from web pages and APIs.

Instructions

Free-form command: automatically fetch if a link is detected, automatically search if a search query is detected.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesFree-form user instruction

Implementation Reference

  • Executes the smart_command tool: parses the command string, detects URLs and fetch keywords to invoke fetchWebpage, otherwise performs Google Custom Search.
    } else if (toolName === 'smart_command') {
      // Smart command: advanced language detection, translation, and query enrichment
      const { command } = args as { command: string };
      const urlRegex = /(https?:\/\/[^\s]+)/gi;
      const fetchRegex = /\b(open|fetch|scrape|show|display|visit|go to)\b/i;
    
      const urlMatch = command.match(urlRegex);
    
      if (fetchRegex.test(command) && urlMatch) {
        // This is a fetch command
        try {
          const result = await this.fetchWebpage(urlMatch[0], {
            blockResources: false, // Force blockResources to be false
            timeout: 60000,
            maxLength: 4000,
            startIndex: 0,
            maxPages: 1,
          });
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        } catch (error: any) {
          return { content: [{ type: 'text', text: 'Gagal fetch: ' + error.message }], isError: true };
        }
      } else {
        // Otherwise, this is a search command
        const apiKey = process.env.APIKEY_GOOGLE_SEARCH;
        const cx = process.env.CX_GOOGLE_SEARCH;
        if (!apiKey || !cx) {
          return { content: [{ type: 'text', text: 'Google Search API key and cx not set. Please set APIKEY_GOOGLE_SEARCH and CX_GOOGLE_SEARCH in environment variable.' }], isError: true };
        }
        const url = new URL('https://www.googleapis.com/customsearch/v1');
        url.searchParams.set('key', apiKey);
        url.searchParams.set('cx', cx);
        url.searchParams.set('q', command);
        try {
          const controller = new AbortController();
          const timeoutId = setTimeout(() => controller.abort(), 20000); // Apply timeout manually
    
          const response = await fetch(url.toString(), {
            method: 'GET',
            headers: {
              'Content-Type': 'application/json'
            },
            signal: controller.signal // Use abort signal for timeout
          });
          clearTimeout(timeoutId);
    
          if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
          }
    
          const data = await response.json(); // Parse JSON directly
    
          let formatted;
          if (data && Array.isArray(data.items)) {
            formatted = data.items.map((item: any) => ({
              title: item.title,
              link: item.link,
              snippet: item.snippet,
            }));
          } else {
            formatted = data; // Fallback to full data if items not found
          }
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(formatted, null, 2),
              },
            ],
          };
        } catch (error: any) {
          console.error('Error during Google Search:', error);
          return { content: [{ type: 'text', text: 'Error during Google Search: ' + error.message }], isError: true };
        }
      }
  • src/index.ts:236-251 (registration)
    Registers the smart_command tool in the list of available tools, including its description and input schema requiring a 'command' string.
    {
      name: 'smart_command',
      description: 'Free-form command: automatically fetch if a link is detected, automatically search if a search query is detected.',
      inputSchema: {
        type: 'object',
        properties: {
          command: {
            type: 'string',
            description: 'Free-form user instruction'
          }
        },
        required: ['command'],
        additionalProperties: false,
        description: 'Free-form command: auto fetch if link detected, auto search if query. Debug option for verbose output/logging.'
      }
    },
  • Defines the input schema for smart_command: an object with a required 'command' string property.
    inputSchema: {
      type: 'object',
      properties: {
        command: {
          type: 'string',
          description: 'Free-form user instruction'
        }
      },
      required: ['command'],
      additionalProperties: false,
      description: 'Free-form command: auto fetch if link detected, auto search if query. Debug option for verbose output/logging.'
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 mentions automatic detection and actions (fetching links, searching queries), but lacks details on error handling, rate limits, authentication needs, or what constitutes a 'link' or 'search query'. This leaves significant gaps in understanding the tool's behavior and constraints.

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 and front-loaded, consisting of a single sentence that directly states the tool's function. It avoids unnecessary words, but could be more structured by explicitly separating the link and query cases or adding brief examples to enhance clarity without sacrificing brevity.

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 a tool that handles multiple actions (fetching and searching) and lacks annotations and an output schema, the description is incomplete. It does not explain return values, error conditions, or how the detection logic works, leaving the AI agent with insufficient context to use the tool effectively compared to its more specific siblings.

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 schema description coverage is 100%, with the parameter 'command' documented as a 'free-form user instruction'. The description adds marginal value by reiterating the auto-fetch and auto-search behavior, but does not provide additional semantics beyond what the schema already states, such as examples or format details. Baseline 3 is appropriate given the high schema coverage.

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 states the tool's purpose as a 'free-form command' that automatically fetches links or searches queries, which is clear but vague. It specifies the verb ('fetch', 'search') and resource types ('link', 'query'), but does not distinguish it from sibling tools like 'fetch_webpage' or 'google_search', leaving ambiguity about when to use this versus those specific tools.

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?

The description provides minimal guidance by stating it triggers based on detecting links or search queries, but it does not specify when to use this tool versus the sibling tools (e.g., 'fetch_webpage' for links, 'google_search' for queries). There are no explicit alternatives, exclusions, or context for usage, offering little help for an AI agent in tool selection.

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/rayss868/MCP-Web-Curl'

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