Secure Public API MCP Server

Secure Public API MCP Server

OAuth-protected FastMCP server exposing eight read-only public APIs (currency, weather, art, pets, dictionary, random images, vehicles) via MCP tools, with optional Gemini LLM-based routing for query selection.

Category
访问服务器

README

Secure Public API MCP Server

FastAPI hosts an OAuth-protected FastMCP server for eight read-only public APIs. The /query convenience endpoint accepts request_id and request_message, then selects the relevant allow-listed API tools.

Routing modes

By default, routing is deterministic and does not need an LLM or API key:

export LLM_ROUTING_ENABLED=false

To enable Gemini reasoning, configure Google Cloud Application Default Credentials (ADC) and restart the server:

export LLM_ROUTING_ENABLED=true
export GOOGLE_CLOUD_PROJECT='your-gcp-project-id'
export GOOGLE_CLOUD_LOCATION='us-central1' # optional
# Optional; defaults to gemini-2.5-flash
export GEMINI_MODEL='gemini-2.5-flash'

For local development, authenticate the Google SDK once:

gcloud auth application-default login

For a deployed workload, attach a service account with Vertex AI access and use its ambient credentials (or set GOOGLE_APPLICATION_CREDENTIALS to the service-account credential file). Do not put a Gemini API key in this project.

With LLM routing enabled, Gemini receives a constrained prompt and must return validated JSON naming only the eight local tools. It cannot access arbitrary URLs, execute code, or bypass authorization. The service validates and bounds each selected argument before calling any public API. If the flag is enabled without project/ADC configuration or the SDK, /query returns 503; it does not silently switch to rule routing.

Local setup

cd /Users/nkrishnakumar/Documents/Mohaan/public-api-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Create the local configuration before starting the app. It prompts for a local password, generates the JWT and OAuth client secrets, and writes every required export to .env.local (which is Git-ignored):

python3 setup.py
source .env.local
uvicorn main:app --reload

Enable Gemini/Vertex AI routing while creating the configuration:

python3 setup.py --llm --gcp-project 'your-gcp-project-id'
source .env.local
gcloud auth application-default login
uvicorn main:app --reload

setup.py configures APP_ENV, JWT issuer/audience/expiry/signing key, allow-listed users and OAuth clients, LLM mode, Google Cloud project/location, and Gemini model. It also exports LOCAL_OAUTH_CLIENT_ID and LOCAL_OAUTH_CLIENT_SECRET for local curl testing. Re-run it whenever you want new local secrets; it replaces .env.local.

The service runs at http://127.0.0.1:8000; OpenAPI documentation is at /docs.

Authentication and authorization

POST /token requires both an approved OAuth client (client_id and client_secret) and an approved user credential. It issues a short-lived JWT containing issuer, audience, expiry, role, and scopes. Every /mcp/* request and /query needs this Bearer token. user has read; admin has read and write. All current public API tools are read-only.

curl -X POST http://127.0.0.1:8000/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d "username=local-user&password=<the-password-you-entered>&client_id=$LOCAL_OAUTH_CLIENT_ID&client_secret=$LOCAL_OAUTH_CLIENT_SECRET"
curl -X POST http://127.0.0.1:8000/query \
  -H 'Authorization: Bearer <access_token>' \
  -H 'Content-Type: application/json' \
  -d '{"request_id":"local-001","request_message":"Show Texas weather alerts and the EUR exchange rate"}' | jq

MCP clients connect to GET /mcp/sse with the same Bearer token and call the tools get_currency_rate, get_artworks, get_dog_pic, get_cat_pic, get_dictionary_meaning, get_weather_alerts, get_random_pic, and get_vehicle_manufacturers.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选