{"id":27885969,"url":"https://github.com/1999azzar/wikipedia-mcp-server","last_synced_at":"2025-05-05T07:50:32.908Z","repository":{"id":290507666,"uuid":"974640914","full_name":"1999AZZAR/wikipedia-mcp-server","owner":"1999AZZAR","description":"Minimal TypeScript-based HTTP server exposing Wikipedia search and page retrieval via MediaWiki API","archived":false,"fork":false,"pushed_at":"2025-04-29T07:31:37.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-29T07:41:07.351Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1999AZZAR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-29T04:57:12.000Z","updated_at":"2025-04-29T07:31:40.000Z","dependencies_parsed_at":"2025-04-29T07:41:09.607Z","dependency_job_id":"0fdf32d0-a92e-47e9-a0c3-567115f7ca3f","html_url":"https://github.com/1999AZZAR/wikipedia-mcp-server","commit_stats":null,"previous_names":["1999azzar/wikipedia-mcp-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Fwikipedia-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Fwikipedia-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Fwikipedia-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Fwikipedia-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1999AZZAR","download_url":"https://codeload.github.com/1999AZZAR/wikipedia-mcp-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252463272,"owners_count":21751757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-05T07:50:31.310Z","updated_at":"2025-05-05T07:50:32.892Z","avatar_url":"https://github.com/1999AZZAR.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wikipedia MCP Server\n\nA minimal TypeScript-based HTTP server exposing Wikipedia search and page retrieval via the MediaWiki API, featuring configurable caching and flexible integration.\n\n## Features\n\n- **Search**: `GET /search?q=QUERY\u0026limit=N\u0026filter=FILTER` for article search with optional title filtering.\n- **Page Fetch**: `GET /page/:title` to retrieve parsed HTML and section data for a given page.\n- **Page Fetch by ID**: `GET /pageid/:id` to retrieve parsed HTML and section data for a given page ID.\n- **Configurable LRU Cache** to speed up repeated requests (`CACHE_MAX`, `CACHE_TTL`).\n- **Security headers** via helmet.\n- **Configurable CORS** origins (`ALLOWED_ORIGINS`).\n- **Rate limiting** by IP+endpoint (`RATE_LIMIT_WINDOW`, `RATE_LIMIT_MAX`).\n- Written in **TypeScript** with full type safety.\n\n## Requirements\n\n- Node.js v14+ or later\n- npm\n\n## Installation\n\n```bash\ngit clone https://github.com/1999AZZAR/wikipedia-mcp-server.git\ncd wikipedia-mcp-server\ncp .env.example .env\nnpm install\nnpm run build\n```\n\n## Configuration\n\nCreate a `.env` file in project root (see `.env.example`):\n\n- `PORT` (default: 3000): HTTP port.\n- `CACHE_MAX` (default: 100): max entries in LRU cache.\n- `CACHE_TTL` (default: 300000): cache entry TTL in milliseconds.\n- `RATE_LIMIT_WINDOW` (default: 60000): rate limit window in milliseconds.\n- `RATE_LIMIT_MAX` (default: 100): max requests per rate limit window.\n- `ALLOWED_ORIGINS` (default: empty): comma-separated CORS origins; leave empty to allow all.\n\n## Running the Server\n\n```bash\nnpm run start\n```\n\nBy default, the server listens on http://localhost:${PORT:-3000}.\n\n## API Documentation\n\nAccess interactive Swagger UI at `http://localhost:3000/docs` (or your configured `PORT`).\n\nRaw OpenAPI spec available at `/openapi.json`.\n\n## API Endpoints\n\n### GET /health\n\nLiveness check endpoint.\n\n**Response**\n```json\n{ \"status\": \"ok\" }\n```\n\n### GET /ready\n\nReadiness check endpoint.\n\n**Response**\n```json\n{ \"status\": \"ready\" }\n```\n\n### GET /search\n\nSearch Wikipedia articles.\n\n| Parameter | Type   | Required | Default | Description                              |\n|-----------|--------|----------|---------|------------------------------------------|\n| q         | string | yes      | —       | Search query                             |\n| limit     | number | no       | 10      | Max number of results                    |\n| filter    | string | no       | —       | Case-insensitive substring filter on titles |\n\n**Response**\n```json\n{ \"results\": [ { \"title\": \"Node.js\", \"snippet\": \"...\", \"pageid\": 12345 }, ... ] }\n```\n\n### GET /page/:title\n\nFetch and parse a Wikipedia page.\n\n| Parameter | Type   | Required | Description                     |\n|-----------|--------|----------|---------------------------------|\n| title     | string | yes      | URL-encoded page title          |\n\n**Response**\n```json\n{ \"page\": { \"title\": \"Node.js\", \"pageid\": 12345, \"text\": \"\u003cp\u003e...\u003c/p\u003e\", \"sections\": [ ... ] } }\n```\n\n### GET /pageid/:id\n\nFetch and parse a Wikipedia page by numeric ID.\n\n| Parameter | Type    | Required | Default | Description          |\n|-----------|---------|----------|---------|----------------------|\n| id        | integer | yes      | —       | Numeric page ID      |\n| lang      | string  | no       | en      | Language code (e.g. en, fr) |\n\n**Response**\n```json\n{ \"page\": { \"title\": \"Node.js\", \"pageid\": 12345, \"text\": \"\u003cp\u003e...\u003c/p\u003e\", \"sections\": [ ... ] } }\n```\n\n## Usage Examples\n### REST - cURL\n```bash\ncurl \"http://localhost:3000/search?q=TypeScript\u0026limit=5\"\ncurl \"http://localhost:3000/page/JavaScript\"\ncurl \"http://localhost:3000/pageid/12345?lang=en\"\n```\n\n### REST - Node.js\n```ts\nimport fetch from 'node-fetch';\nasync function restQuery() {\n  const res = await fetch('http://localhost:3000/search?q=Express');\n  console.log(await res.json());\n}\nrestQuery();\n\nasync function getById() {\n  const res = await fetch('http://localhost:3000/pageid/12345?lang=en');\n  console.log(await res.json());\n}\ngetById();\n```\n\n### GraphQL - cURL\n```bash\ncurl -X POST http://localhost:3000/graphql \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"query\":\"{ search(q:\\\"Node.js\\\") { title snippet pageid } }\"}'\n```\n\n### GraphQL - Node.js\n```ts\nimport { ApolloClient, InMemoryCache, gql } from '@apollo/client';\nconst client = new ApolloClient({\n  uri: 'http://localhost:3000/graphql',\n  cache: new InMemoryCache()\n});\nclient.query({\n  query: gql`{ page(title: \"TypeScript\") { title text } }`\n}).then(console.log);\n\nclient.query({\n  query: gql`{ pageById(id: 21721040) { title text sections } }`\n}).then(console.log);\n```\n\n### JSON-RPC - Node.js (stdin/stdout)\n```ts\nimport { StdioTransport } from './src/transport';\nimport { JSONRPCServer } from './src/jsonrpc';\n\nconst transport = new StdioTransport();\nconst rpcServer = new JSONRPCServer(transport);\nrpcServer.on('search', async ({ q, limit }) =\u003e {\n  // implement your handler, e.g. call wikiSearch(q, limit)\n  return /* result */;\n});\nawait rpcServer.start();\n```\n\n## Testing\nRun unit tests:\n```bash\nnpm test\n```\n\n## Integration\n\n### Standalone Server\n\nRun as a separate service and call endpoints over HTTP from your application or microservices.\n\n### Embedding in Your Express App\n\nImport handlers (if exposed) or proxy requests:\n\n```ts\nimport express from 'express';\nimport proxy from 'http-proxy-middleware';\nconst app = express();\n\n// Proxy to Wikipedia MCP server\napp.use('/api', proxy({ target: 'http://localhost:3000', changeOrigin: true }));\n\napp.listen(4000);\n```\n\n*Alternatively*, extract request logic from `src/server.ts` to use functions directly in your codebase.\n\n## Desktop App Integration\n\nUse a JSON config in your desktop (e.g., Electron) app:\n\n```json\n// config.json\n{\n  \"mcpServer\": {\n    \"baseUrl\": \"http://localhost:3000\",\n    \"timeout\": 5000\n  }\n}\n```\n\nLoad and call endpoints:\n\n```ts\nimport config from './config.json';\n\nconst { baseUrl, timeout } = config.mcpServer;\n\nasync function search(query: string) {\n  const res = await fetch(`${baseUrl}/search?q=${encodeURIComponent(query)}`, { timeout });\n  return res.json();\n}\n\nasync function getPage(title: string) {\n  const res = await fetch(`${baseUrl}/page/${encodeURIComponent(title)}`, { timeout });\n  return res.json();\n}\n\nasync function getPageById(id: number) {\n  const res = await fetch(`${baseUrl}/pageid/${id}?lang=en`, { timeout });\n  return res.json();\n}\n```\n\n## GraphQL API\n\nInteractive GraphQL Playground at `http://localhost:${PORT:-3000}/graphql`.\n\n**Example Query**\n```graphql\nquery {\n  search(q: \"TypeScript\", limit: 5) {\n    title\n    snippet\n    pageid\n  }\n}\n```\n```graphql\nquery GetPage { page(title: \"Node.js\") { title pageid text sections } }\n```\n```graphql\nquery GetPageById {\n  pageById(id: 21721040) {\n    title\n    text\n    sections\n  }\n}\n```\n\n## SDK Generation\n\nAuto-generate a TypeScript client from OpenAPI:\n```bash\nnpm run gen:client\n```\nClient will appear at `src/sdk/client.ts`, which you can import:\n```ts\nimport { paths } from './sdk/client';\n```\nUse this for typed REST calls in your apps.\n\n## Docker (Optional)\n\n```dockerfile\nFROM node:16\nWORKDIR /app\nCOPY . .\nRUN npm install \u0026\u0026 npm run build\nCMD [\"npm\",\"run\",\"start\"]\n```\n\n## Contributing\n\nContributions welcome! Please open issues or PRs for features and bug fixes.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1999azzar%2Fwikipedia-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1999azzar%2Fwikipedia-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1999azzar%2Fwikipedia-mcp-server/lists"}