Trefle Botanical MCP
Python MCP server for the Trefle global botanical taxonomy, plant species, and growth traits database
Documentation
trefle-mcp
A small, read-only Model Context Protocol server for the public Trefle botanical REST API, built as a concrete answer to treflehq/trefle-api#225 ("Official MCP server exposing Trefle search and species data").
It is a clean-room implementation: written from the public API contract (routes, query keys, error envelope) and not derived from Trefle's source code. Not affiliated with or endorsed by Trefle.
Tools
| Tool | Trefle endpoint | Notes |
|---|---|---|
search_species(q, filters?, ranges?, page, limit) | GET /api/v1/species/search | full-text search, optional filter[...] / range[...] |
get_species(id_or_slug) | GET /api/v1/species/{id} | full species card |
list_plants(filters?, ranges?, page, limit) | GET /api/v1/plants | "plants by growing conditions" |
species_in_distribution(zone, establishment?, page, limit) | GET /api/v1/distributions/{zone}/species | native / introduced filter |
These are the four endpoints proposed in the issue (search, species show, plants list with filters, distributions).
Design decisions (the open questions in #225)
- Transport: stdio. Each user brings their own token, so there is no hosted state or shared quota. A Streamable HTTP mode is a small follow-up if Trefle wants a hosted endpoint.
- Auth:
TREFLE_TOKENenv var only. Sent asAuthorization: Bearer, never as?token=, so it does not leak into URLs, logs or tool output. The server fails fast with a clear message if it is missing. - Context budget: list results are trimmed to id/slug/names/family/genus/year/image and
limitis capped at 50 per call;has_next_pageandtotaltell the agent whether to paginate. - Validation: unknown
filter/rangekeys are rejected locally (same allow-list as the API) before any request, so the agent gets an actionable error without spending a request. - Errors: Trefle's
{error, code, message, details}envelope is returned to the agent as structured JSON instead of a stack trace. - Repo placement: works as a standalone package (
treflehq/trefle-mcp) or as a folder in the main repo.
1-Click Client Configuration & Quickstart
- 1-Click Claude Desktop Bundle (
.mcpb): Downloadtrefle-mcp.mcpband open it in Claude Desktop. - Zero-Clone
uvxConfig (Claude Desktop / Cursor / VS Code):
{
"mcpServers": {
"trefle": {
"command": "uvx",
"args": [
"--from",
"https://github.com/khoap1220-hue/trefle-mcp/releases/latest/download/trefle_mcp-0.1.2-py3-none-any.whl",
"trefle-mcp"
],
"env": {
"TREFLE_TOKEN": "your-trefle-token"
}
}
}
}
Local Source Install
pip install -e ".[test]"
export TREFLE_TOKEN=... # from your trefle.io account
python -m trefle_mcp.server # stdio
Tests
Fully offline: HTTP is mocked with respx, and one test spawns the real stdio server and runs the MCP
handshake + tools/list against it. No token or network needed.
PYTHONDONTWRITEBYTECODE=1 python -B -m pytest -q
Roadmap (Planned Next Phases)
Retry with Retry-After on 429/5xx, lang parameter for localized common names, species/{id}/facts provenance tool, and remote Streamable HTTP transport.
License
MIT
Custom Enterprise MCP & Webhook Engineering
Need a production-hardened MCP server (OAuth 2.1, tenant scoping, annotation mutation guards, Official Registry server.json + Glama Grade-A) or replay-safe Stripe/HubSpot/n8n webhook integration?
- 48h Fixed Starter Slice: $145 via 0%-fee Contra Escrow (100% async — written spec, tested GitHub PR & 2-min walkthrough)
- Portfolio & Services: khoaphan.dev/services
Related Open-Source MCP & A2A Security Suite
| Project | Focus & Verification |
|---|---|
mcp-tool-guard & a2a-card-guard | Zero-dep MCP & A2A v1.0 security guard, 11-CVE multi-lang SCA, RFC 8785 JCS/JWKS verifier & GitHub Action (Featured in awesome-a2a) |
caido-mcp · anythingllm-mcp | Official Anthropic MCP Registry servers for Caido AppSec HTTPQL traffic/findings & AnythingLLM RAG workspaces with fail-closed ACLs |
blender-mcp-suite · shopnex-mcp | Official Anthropic MCP Registry servers for 21-tool Blender 4.1+ 3D automation (zero-zombie Job Objects) & ShopNex e-commerce operations |
wakatime-mcp · trefle-mcp | Read-only Official Anthropic MCP Registry servers for WakaTime developer productivity telemetry & Trefle botanical species data |
khoaphan.dev | Architecture notes, live Ed25519-signed A2A v1.0.1 node & custom MCP engineering sprints (100% written async, zero live meetings) |