dynamic-discord-bot-api-mcp

dynamic-discord-bot-api-mcp

MCP server for Discord bot API that exposes five tools to search, inspect, and call stable Discord HTTP endpoints using bot-token authentication, with automatic schema refresh and strict safety filtering.

Category
访问服务器

README

dynamic-discord-bot-api-mcp

Production-oriented stdio MCP gateway exposing stable Discord HTTP operations that explicitly support bot-token authentication. It installs a checked-in, self-refreshing OpenAPI catalog and exposes exactly five generic tools—never one tool per endpoint.

Discord's OpenAPI specification is a public preview and may be incomplete. This project consumes only stable openapi.json; official Discord documentation remains authoritative.

Scope and architecture

Refresh filters every operation by explicit BotToken security metadata, then applies a small fail-closed classifier for OAuth, interaction-token, webhook-token, Social SDK/lobby, and ambiguous routes. It retains only transitively referenced component schemas. Excluded endpoints cannot be searched, inspected, or called.

Gateway HTTP metadata such as /gateway/bot may remain because it supports bot authentication; Gateway WebSockets and events do not. Also excluded: OAuth exchange, bearer/user authorization, self-bots, Voice WebSocket/RTP, RPC, Activities/Embedded App/Social SDKs, interaction receivers/callbacks, incoming webhook servers, webhook-token execution, preview endpoints, and arbitrary HTTP requests.

Runtime resolves one active local MCP workspace root, reloads its .env before every call, and caches a client only while security-relevant configuration is unchanged. Schema refresh uses validation, atomic rename, concurrent coalescing, and cached fallback. JSON audit events go to stderr without values or secrets.

Install

npm install -g dynamic-discord-bot-api-mcp
discord-bot-api-mcp

From GitHub:

npm install -g github:PrimeUpYourLife/dynamic-discord-bot-api-mcp

MCP client configuration:

{"mcpServers":{"discord":{"command":"discord-bot-api-mcp"}}}

Codex ~/.codex/config.toml:

[mcp_servers.discord]
command = "discord-bot-api-mcp"

Place DISCORD_BOT_TOKEN in active repository .env. Process environment overrides startup-directory .env; active workspace .env overrides both. Multiple, failed, non-local, or non-directory MCP roots fail closed. Catalog tools need no token.

Five tools

  • discord_search_endpoints: fuzzy search IDs, methods, routes, categories, descriptions, and parameters.
  • discord_get_endpoint: exact canonical ID or OpenAPI operation-ID lookup.
  • discord_get_type: component-schema lookup.
  • discord_call_endpoint: validate and execute a cataloged bot endpoint.
  • discord_refresh_schema: fetch, filter, validate, and atomically install stable schema.

Examples:

{"search":"create message","limit":5}
{"endpoint":"create_message"}
{"endpoint":"POST /channels/{channel_id}/messages","pathParameters":{"channel_id":"123456789012345678"},"body":{"content":"Hello from MCP"}}

Upload example:

{"endpoint":"create_message","pathParameters":{"channel_id":"123456789012345678"},"body":{"content":"image"},"files":[{"path":"./uploads/image.png","filename":"image.png","contentType":"image/png"}]}

Uploads use payload_json and deterministic files[n] parts/attachment IDs. Paths resolve from active root and must remain within configured realpath roots. Base64 descriptors are also supported.

Validation separates path, query, and body values; handles required fields, nested objects, arrays, enums, nullable values, refs and unions. Snowflakes remain strings. Arrays become repeated query keys. DELETE and centrally classified destructive operations require confirm: true. Optional audit reason is percent-encoded.

Errors are structured (ENDPOINT_NOT_FOUND, ENDPOINT_NOT_ALLOWED, CONFIRMATION_REQUIRED, BOT_TOKEN_MISSING, VALIDATION_ERROR, DISCORD_API_ERROR, REQUEST_ERROR, project-root errors, or SCHEMA_REFRESH_FAILED). Discord numeric codes and nested validation errors are preserved; raw bodies, stack traces, and tokens are not.

Configuration

Variable Default Meaning
DISCORD_BOT_TOKEN unset Bot token; calls fail safely when absent
DISCORD_API_BASE_URL https://discord.com/api/v10 Fixed API origin
DISCORD_ENDPOINT_ALLOWLIST * Comma-separated IDs/operation IDs with * globs
DISCORD_REQUEST_TIMEOUT_MS 30000 Per-attempt timeout
DISCORD_REQUEST_RETRIES 2 Retry count
DISCORD_RATE_LIMIT_PER_SECOND 45 Local global safety rate
DISCORD_RATE_LIMIT_BURST 50 Local burst
DISCORD_SCHEMA_MAX_AGE_HOURS 24 Refresh threshold
DISCORD_SCHEMA_PATH bundled catalog Alternate catalog path
DISCORD_LOCAL_FILE_ROOTS active root Platform-delimited upload roots
DISCORD_MAX_UPLOAD_BYTES 10485760 Per-file limit
DISCORD_ALLOW_UNKNOWN_PARAMETERS false Validation escape hatch
LOG_LEVEL info debug, info, warn, error

Use narrow production allowlists. Caller cannot supply URLs, methods, authorization, or headers. Requests always use configured base URL plus catalog route, Authorization: Bot …, and valid package User-Agent.

Discord response headers and 429 payloads control per-route/bucket and global waits; limits are not hard-coded. Fractional retry_after is honored. 429s retry within configured bound. 5xx and transport retries are limited to safe GET requests, preventing duplicate messages or moderation actions.

Development

npm ci
npm run refresh-schema
npm run check
npm test
npm run build

Tests mock network access. Daily workflow refreshes catalog and commits only generated-data changes. Manual publish workflow verifies tag/version and uses npm trusted publishing via GitHub OIDC; prereleases publish under next.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选