Skip to main content
Glama
by shiquda

search

Find relevant wiki pages by entering a search query and specifying the number of results. Supports MediaWiki sites like Wikipedia, Fandom, and Wiki.GG.

Instructions

Search for a wiki page. The shorter the request, the better, preferably containing only the main term to be searched. Args: query: The query to search for limit: The number of results to return Returns: A list of pages that match the query

Input Schema

NameRequiredDescriptionDefault
limitNo
queryYes

Input Schema (JSON Schema)

{ "properties": { "limit": { "default": 5, "title": "Limit", "type": "integer" }, "query": { "title": "Query", "type": "string" } }, "required": [ "query" ], "title": "searchArguments", "type": "object" }

Implementation Reference

  • The handler function for the 'search' tool. It is decorated with @mcp.tool() for registration and includes type hints and docstring serving as schema. Makes an API request to search MediaWiki pages.
    @mcp.tool() async def search(query: str, limit: int = 5): """ Search for a wiki page. The shorter the request, the better, preferably containing only the main term to be searched. Args: query: The query to search for limit: The number of results to return Returns: A list of pages that match the query """ path = "search/page" params = { "q": query, "limit": limit, } response = await make_request(path, params) return response
  • Helper utility function used by the 'search' tool to make HTTP requests to the MediaWiki API, handling proxies and redirects.
    async def make_request(path: str, params: dict) -> httpx.Response: headers = { "User-Agent": USER_AGENT, } url = config.base_url + config.path_prefix + path proxies = get_proxy_settings() async with httpx.AsyncClient(proxies=proxies, follow_redirects=True) as client: try: response = await client.get(url, headers=headers, params=params) if response.status_code in (301, 302, 303, 307, 308): final_response = await client.get( response.headers["Location"], headers=headers ) return final_response.json() return response.json() except httpx.HTTPStatusError as e: logger.error(e) return {"error": e}
  • Helper function to retrieve proxy settings from environment, used by make_request.
    def get_proxy_settings(): """Get proxy settings from environment variables""" http_proxy = os.environ.get("HTTP_PROXY") return http_proxy

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/shiquda/mediawiki-mcp-server'

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