Guardian Mcp Server

io.github.cyanheads由 GitHub 账号 cyanheads 发布v0.2.0更新于 Oct 24, 2026

Guardian Open Platform: search and retrieve full article text from The Guardian archive.

概览

AI 生成的概览

通过《卫报》开放平台 API 检索、浏览并获取《卫报》档案(1999 年至今)的全文文章。

可以做什么
  • 用布尔查询、栏目、标签、作者和日期筛选检索文章,并支持排序与分页
  • 按路径 slug ID 获取单篇文章,返回去除 HTML 的正文、元数据和作者信息
  • 按栏目或标签浏览最新内容,并列出可用栏目与标签以发现筛选条件
适用场景
适合助手需要《卫报》报道做研究、新闻摘要、引文或来源收集,或按栏目、标签、作者整理筛选后的阅读清单时使用。
运行要求
通过 npx、bunx 或 Docker 在本地运行;使用包方式需 Bun v1.4.0+ 或 Node.js v24+。需要 GUARDIAN_API_KEY 中的免费《卫报》开放平台 API 密钥,并能访问《卫报》API 的网络。可选配置涵盖传输方式、HTTP 主机与端口、认证模式、日志和 OpenTelemetry。
安装前请注意
API 密钥通过 GUARDIAN_API_KEY 环境变量传入,应避免写入共享配置。三个工具对《卫报》API 均为只读,但查询和文章请求会发送给第三方。免费开发者层级仅限非商业用途且有速率限制(每天 5,000 次请求、每秒 12 次调用),服务器不额外限流。启用 LOG_TOOL_FAILURE_PAYLOADS 会记录失败的工具参数,自由文本中的密钥可能仍可见。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Guardian Mcp Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

@cyanheads/guardian-mcp-server

Search, browse, and retrieve full article text from The Guardian's journalism archive (1999–present) via MCP. STDIO or Streamable HTTP.

3 Tools


Overview

The Guardian's journalism archive, 1999 to today. Search full text, browse by section or tag, and fetch individual articles.

Tools

ToolDescription
guardian_search_articlesFull-text search across The Guardian's archive with optional section, tag, contributor, and date filters
guardian_get_articleFetch a single Guardian article by ID with body text and metadata
guardian_browse_contentBrowse by section or tag, or discover available sections and tags, across four modes

Capability reference

guardian_search_articles tool

  • Boolean query syntax (AND/OR/NOT, quoted phrases), optional section/tag/contributor and from_date/to_date (YYYY-MM-DD) filters; order_by: relevance (default), newest, or oldest; page + page_size (1–50, default 10)
  • Articles carry metadata, HTML-stripped body text and a truncated flag; results include total, page, pages, page_size, and order_by
  • Fails with no_results or invalid_date (dates must be real calendar dates)
  • tag accepts comma (AND), pipe | (OR), hyphen - (NOT), and parentheses, e.g. environment/climate-crisis|environment/flooding. Wrap an OR expression in parentheses when also passing contributor.

guardian_get_article tool

  • Required article_id: the path-slug id returned by guardian_search_articles or guardian_browse_content
  • Returns HTML-stripped body text, metadata, contributors, pillar/section classification, and truncated
  • Fails with not_found

guardian_browse_content tool

  • Four mode values: section_latest (requires section_id), tag_latest (requires tag_id), list_sections, list_tags; page + page_size (1–50, default 10) for articles and tags
  • list_tags filters by optional query and tag_type (keyword, contributor, blog, series, tone, type, publication, newspaper-book, newspaper-book-section); output carries mode, total, and the matching results/sections/tags array
  • Fails with missing_section_id, missing_tag_id, section_not_found, or tag_not_found. tag_id accepts the same boolean expressions as search's tag.

All three tools also fail with status-specific HTTP errors. Not retryable: unauthorized (401), access_denied (403), request_rejected (400), validation_failed (422), invalid_request, request_conflict, request_not_found, and api_unsupported (501). Retryable: api_timeout (408/425/504), rate_limited (429), and api_error (other 5xx). Each error carries a recovery hint.


Features

Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.

Guardian-specific:

  • Wraps the Guardian Open Platform API with a free non-commercial developer key
  • Full body text extraction — HTML stripped, not just headlines or abstracts
  • Contributor ID discovery via guardian_browse_content mode list_tags with tag_type=contributor
  • Section and tag taxonomy browsing (list_sections, list_tags) for filter discovery before searching
  • Free tier: 5,000 requests/day, 12 calls/second — the server applies no additional throttling

Agent-friendly output:

  • Search and article-returning browse modes cap previews at 2,000 words and set truncated; call guardian_get_article for the full text
  • Typed error reasons across all three tools, each paired with a recovery hint
  • total / page / pages on every paginated response so callers can track result scope

Getting started

Add the following to your MCP client configuration file. Register for a free Guardian Open Platform API key at open-platform.theguardian.com/access.

json
{  "mcpServers": {    "guardian-mcp-server": {      "type": "stdio",      "command": "bunx",      "args": ["@cyanheads/guardian-mcp-server@latest"],      "env": {        "MCP_TRANSPORT_TYPE": "stdio",        "MCP_LOG_LEVEL": "info",        "GUARDIAN_API_KEY": "your-api-key"      }    }  }}

Or with npx (no Bun required):

json
{  "mcpServers": {    "guardian-mcp-server": {      "type": "stdio",      "command": "npx",      "args": ["-y", "@cyanheads/guardian-mcp-server@latest"],      "env": {        "MCP_TRANSPORT_TYPE": "stdio",        "MCP_LOG_LEVEL": "info",        "GUARDIAN_API_KEY": "your-api-key"      }    }  }}

Or with Docker:

json
{  "mcpServers": {    "guardian-mcp-server": {      "type": "stdio",      "command": "docker",      "args": [        "run", "-i", "--rm",        "-e", "MCP_TRANSPORT_TYPE=stdio",        "-e", "GUARDIAN_API_KEY=your-api-key",        "ghcr.io/cyanheads/guardian-mcp-server:latest"      ]    }  }}

For Streamable HTTP, set the transport and start the server:

sh
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 GUARDIAN_API_KEY=your-api-key bun run start:http# Server listens at http://localhost:3010/mcp

Prerequisites

Installation

  1. Clone the repository:
sh
git clone https://github.com/cyanheads/guardian-mcp-server.git
  1. Navigate into the directory:
sh
cd guardian-mcp-server
  1. Install dependencies:
sh
bun install
  1. Configure environment:
sh
cp .env.example .env# Edit .env and set GUARDIAN_API_KEY

Configuration

VariableDescriptionDefault
GUARDIAN_API_KEYRequired. Free developer key from open-platform.theguardian.com/access.—
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTPort for HTTP server.3010
MCP_SESSION_MODEHTTP session mode: stateless, stateful, or auto (resolves to stateful). The server declares stateless; an exported value overrides it.stateless
MCP_AUTH_MODEAuth mode: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (RFC 5424).info
LOGS_DIRDirectory for log files (Node.js only).<project-root>/logs
LOG_TOOL_FAILURE_PAYLOADSLog failed tool arguments and results, redacted by key name and capped by LOG_TOOL_FAILURE_PAYLOAD_MAX_BYTES (default 16384). Secrets in free-form values remain visible.false
STORAGE_PROVIDER_TYPEStorage backend.in-memory
OTEL_ENABLEDEnable OpenTelemetry instrumentation (spans, metrics, completion logs).false
OTEL_EXPORTER_OTLP_ENDPOINTBase OTLP URL; traces use /v1/traces, metrics use /v1/metrics.—
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTOpt-in OTLP log endpoint, used as-is.—

See .env.example for the full list of optional overrides.


Running the server

Local development

  • Build and run:

    sh
    # One-time buildbun run rebuild
    # Run the built serverbun run start:stdio# orbun run start:http
  • Run checks and tests:

    sh
    bun run devcheck   # Lint, format, typecheck, securitybun run test       # Vitest test suitebun run lint:mcp   # Validate MCP definitions against spec

Docker

sh
docker build -t guardian-mcp-server .docker run --rm -e GUARDIAN_API_KEY=your-api-key -p 3010:3010 guardian-mcp-server

The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/guardian-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.


Project structure

DirectoryPurpose
src/index.tscreateApp() entry point — registers tools and initializes the Guardian service.
src/configServer-specific environment variable parsing (GUARDIAN_API_KEY).
src/mcp-server/toolsTool definitions (*.tool.ts): guardian_search_articles, guardian_get_article, guardian_browse_content.
src/services/guardianGuardian Open Platform API client, normalization, and type definitions.
tests/Unit and integration tests.
docs/Design document and directory tree.

Development guide

See CLAUDE.md / AGENTS.md for development guidelines and architectural rules. The short version:

  • Handlers throw, framework catches — no try/catch in tool logic
  • Use ctx.log for request-scoped logging, ctx.state for tenant-scoped storage
  • Register new tools in the createApp() tools array in src/index.ts
  • Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields

Contributing

Issues are welcome. Run checks and tests before submitting:

sh
bun run devcheckbun run test

License

Apache-2.0 — see LICENSE for details.


Powered by The Guardian.

来源:README.md,提交 dba8632

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

4
  1. v0.2.0最新Oct 16, 2026
  2. v0.1.5Oct 8, 2026
  3. v0.1.4Sep 22, 2026
  4. v0.1.3Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分