Skip to content

docs(examples): add Lore Context MCP server example#4082

Open
zhushuanbao-dot wants to merge 1 commit intoPrefectHQ:mainfrom
zhushuanbao-dot:feature/lore-context-example
Open

docs(examples): add Lore Context MCP server example#4082
zhushuanbao-dot wants to merge 1 commit intoPrefectHQ:mainfrom
zhushuanbao-dot:feature/lore-context-example

Conversation

@zhushuanbao-dot
Copy link
Copy Markdown

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:

Tool Lore Endpoint Description
memory_search POST /v1/memory/search Semantic search over memories
memory_write POST /v1/memory/write Store governed memories
memory_get GET /v1/memory/{id} Fetch by ID
memory_list GET /v1/memory/list List with filters
memory_forget POST /v1/memory/forget Soft/hard delete

Files

File Description
examples/lore_context_server/server.py FastMCP server with 5 tools
examples/lore_context_server/README.md Setup, config, Claude Desktop integration
examples/lore_context_server/pyproject.toml Dependencies (fastmcp + httpx)
examples/lore_context_server/.fastmcp.json Config for fastmcp run

Pattern

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

  • No changes to FastMCP core code
  • Third-party integration as a self-contained example only

🤖 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.

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.
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@marvin-context-protocol marvin-context-protocol Bot added documentation Updates to docs, examples, or guides. Primary change is documentation-related. too-long Excessively verbose or unedited LLM output. Condense before triage. labels Apr 29, 2026
@marvin-context-protocol
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +83 to +84
scope: str = "project",
project_id: str | None = None,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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", "")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Updates to docs, examples, or guides. Primary change is documentation-related. too-long Excessively verbose or unedited LLM output. Condense before triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant