Skip to main content
Glama

smart_command

Automate web data retrieval and search tasks by issuing free-form commands; fetches links or searches the web based on user instructions.

Instructions

Perintah bebas: otomatis fetch jika ada link, otomatis search jika ada kata "cari di internet".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesInstruksi bebas dari user

Implementation Reference

  • Handler logic for 'smart_command' tool. Parses the command: if it contains a URL and fetch-related keywords, fetches the webpage using fetchWebpage; otherwise, performs a 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:225-240 (registration)
    Registration of 'smart_command' tool in the ListTools response, including name, description, and input schema.
    { 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.' } },
  • Input schema definition for 'smart_command' tool.
    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.' }

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

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