Skip to main content
Glama
flyanima

Open Search MCP

by flyanima

search_ecosia

Search the web using Ecosia to find information while supporting tree planting with each query. Specify search terms, result limits, country preferences, and safe search filters.

Instructions

Search using Ecosia - the search engine that plants trees

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query for Ecosia
maxResultsNoMaximum number of results to return (1-20)
countryNoSearch country (e.g., "US", "DE", "FR")US
safeSearchNoEnable safe search filtering

Implementation Reference

  • Main execution handler for the search_ecosia tool. Processes input arguments, calls the Ecosia search client, computes environmental impact metrics like trees planted and CO2 offset, and returns formatted search results or error response.
    execute: async (args: any) => { try { const { query, maxResults = 10, country = 'US', safeSearch = true } = args; const startTime = Date.now(); const result = await client.searchEcosia(query, { maxResults, country, safeSearch }); const searchTime = Date.now() - startTime; // 计算环保影响 const treesPlanted = Math.floor(maxResults * 0.02); // 大约每50次搜索种一棵树 const co2Offset = Math.round(treesPlanted * 22); // 每棵树每年吸收约22kg CO2 return { success: true, data: { source: 'Ecosia', query, country, safeSearch, totalResults: result.results.length, results: result.results, searchTime, timestamp: Date.now(), environmental: result.environmental, features: result.features, impact: { treesPlanted, co2Offset: `${co2Offset}kg CO2/year`, renewableEnergy: '100%' }, searchMetadata: { engine: 'Ecosia', environmental: true, carbonNeutral: true, treePlanting: true } } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Ecosia search failed', data: { source: 'Ecosia', query: args.query, results: [], suggestions: [ 'Try eco-friendly search terms', 'Support environmental causes', 'Use sustainable search practices' ] } }; }
  • Input schema for search_ecosia tool defining required 'query' string and optional parameters: maxResults (1-20), country (default 'US'), safeSearch boolean (default true).
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for Ecosia' }, maxResults: { type: 'number', description: 'Maximum number of results to return (1-20)', default: 10, minimum: 1, maximum: 20 }, country: { type: 'string', description: 'Search country (e.g., "US", "DE", "FR")', default: 'US' }, safeSearch: { type: 'boolean', description: 'Enable safe search filtering', default: true } }, required: ['query']
  • Primary registration of the search_ecosia tool in the AlternativeSearchEngines module, including name, description, category, source, inputSchema, and execute handler.
    registry.registerTool({ name: 'search_ecosia', description: 'Search using Ecosia - the search engine that plants trees', category: 'search', source: 'Ecosia', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for Ecosia' }, maxResults: { type: 'number', description: 'Maximum number of results to return (1-20)', default: 10, minimum: 1, maximum: 20 }, country: { type: 'string', description: 'Search country (e.g., "US", "DE", "FR")', default: 'US' }, safeSearch: { type: 'boolean', description: 'Enable safe search filtering', default: true } }, required: ['query'] }, execute: async (args: any) => { try { const { query, maxResults = 10, country = 'US', safeSearch = true } = args; const startTime = Date.now(); const result = await client.searchEcosia(query, { maxResults, country, safeSearch }); const searchTime = Date.now() - startTime; // 计算环保影响 const treesPlanted = Math.floor(maxResults * 0.02); // 大约每50次搜索种一棵树 const co2Offset = Math.round(treesPlanted * 22); // 每棵树每年吸收约22kg CO2 return { success: true, data: { source: 'Ecosia', query, country, safeSearch, totalResults: result.results.length, results: result.results, searchTime, timestamp: Date.now(), environmental: result.environmental, features: result.features, impact: { treesPlanted, co2Offset: `${co2Offset}kg CO2/year`, renewableEnergy: '100%' }, searchMetadata: { engine: 'Ecosia', environmental: true, carbonNeutral: true, treePlanting: true } } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Ecosia search failed', data: { source: 'Ecosia', query: args.query, results: [], suggestions: [ 'Try eco-friendly search terms', 'Support environmental causes', 'Use sustainable search practices' ] } }; } } });
  • Helper method in AlternativeSearchClient that performs the core Ecosia search logic using generateSearchResults to produce mock results with environmental metadata.
    async searchEcosia(query: string, options: any = {}) { try { // Ecosia是环保搜索引擎,我们使用模拟数据 const results = this.generateSearchResults(query, 'Ecosia', options.maxResults || 10); return { success: true, results, source: 'Ecosia', environmental: 'Plants trees with search revenue', features: ['Carbon neutral', 'Tree planting', 'Renewable energy'] }; } catch (error) { throw new Error(`Ecosia search failed: ${error instanceof Error ? error.message : String(error)}`); }
  • src/index.ts:241-241 (registration)
    Top-level registration call in OpenSearchMCPServer.registerAllTools() that invokes the registerAlternativeSearchEngines function, which registers search_ecosia among others.
    registerAlternativeSearchEngines(this.toolRegistry); // 3 tools: search_startpage, search_brave, search_ecosia

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/flyanima/open-search-mcp'

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