docs(examples): add Lore Context MCP server example#4082
docs(examples): add Lore Context MCP server example#4082zhushuanbao-dot wants to merge 1 commit intoPrefectHQ:mainfrom
Conversation
Adds a FastMCP server example that wraps the Lore Context REST API, exposing governed agent memory tools (search, write, get, list, forget) for any MCP-compatible client.
|
Thanks for the report. This issue goes beyond what our contributor guidelines ask for — we just need a short problem description and an MRE. Please see our contributing guidelines and condense this issue. We'll triage it once it's trimmed down. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ca6dd5895
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| scope: str = "project", | ||
| project_id: str | None = None, |
There was a problem hiding this comment.
Avoid invalid default scope in memory_write
memory_write defaults scope to "project" while project_id remains optional, but this same function documents that project_id is required for project scope. That makes the simplest valid MCP call shape (content only) produce a guaranteed 4xx from the Lore API, so the tool’s defaults are internally inconsistent and lead to immediate runtime failures for clients that rely on default arguments.
Useful? React with 👍 / 👎.
| # --------------------------------------------------------------------------- | ||
|
|
||
| LORE_API_URL = os.environ.get("LORE_API_URL", "http://127.0.0.1:3000").rstrip("/") | ||
| LORE_API_KEY = os.environ.get("LORE_API_KEY", "") |
There was a problem hiding this comment.
Fail fast when LORE_API_KEY is unset
The server treats LORE_API_KEY as optional by defaulting it to an empty string, even though the README and module docstring mark it as required. In that configuration every tool call sends Authorization: Bearer and fails later with HTTP errors, so users get a server that starts successfully but cannot perform any operation; this should be rejected at startup with a clear configuration error.
Useful? React with 👍 / 👎.
Why
FastMCP makes building MCP servers easy, but there's no example showing how to wrap an external REST API as an MCP server. This example demonstrates building a Lore Context semantic memory server using FastMCP — a practical pattern for any REST-to-MCP bridge.
What
A complete MCP server that exposes 5 Lore Context tools:
memory_searchPOST /v1/memory/searchmemory_writePOST /v1/memory/writememory_getGET /v1/memory/{id}memory_listGET /v1/memory/listmemory_forgetPOST /v1/memory/forgetFiles
examples/lore_context_server/server.pyexamples/lore_context_server/README.mdexamples/lore_context_server/pyproject.tomlexamples/lore_context_server/.fastmcp.jsonfastmcp runPattern
This example establishes a useful pattern: REST-to-MCP bridge using FastMCP's decorator API. Any REST API can be wrapped as an MCP server in ~100 lines.
Non-goals
🤖 About this contribution
This PR was drafted by lorecmo, an AI agent operating under direct human supervision (account owner: zhushuanbao @ REDLAND PTE. LTD., Singapore).
The integration design and final diff have been reviewed by a human contributor before submission.