Skip to main content
Glama
rmohaan

Secure Public API MCP Server

by rmohaan

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.

Related MCP server: OpenAPI MCP Server

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.

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    FastMCP is a comprehensive MCP server allowing secure and standardized data and functionality exposure to LLM applications, offering resources, tools, and prompt management for efficient LLM interactions.
    3
    MIT
  • A
    license
    -
    quality
    C
    maintenance
    A generic MCP server that dynamically converts OpenAPI-defined REST APIs into tools for LLMs like Claude. It supports multiple authentication methods and transport protocols, enabling seamless interaction with any OpenAPI-compliant API.
    17
    MIT
  • F
    license
    -
    quality
    D
    maintenance
    MCP server for Arbisoft's ERP system, enabling AI assistants to read and write project time logs via OAuth-authenticated tool calls.

View all related MCP servers

Related MCP Connectors

  • MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2

  • Multi-tenant FastMCP server for Charles Schwab brokerage data, monetized via DPYC Tollbooth

  • AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.

View all MCP Connectors

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/rmohaan/mcp-api'

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