"""MCP Resource definitions for the Knowledge Layer."""
from mcp.server import Server
from .app_context import get_app_context
from .user_archetypes import get_user_archetypes
from .keyword_research import get_keyword_research
def register_knowledge_resources(server: Server) -> None:
"""Register all knowledge resources with the MCP server.
Args:
server: The MCP server instance.
"""
@server.list_resources()
async def list_resources():
"""List available knowledge resources."""
return [
{
"uri": "knowledge://app/context",
"name": "App Context",
"description": "Product/app information, value propositions, and target audiences",
"mimeType": "application/json",
},
{
"uri": "knowledge://users/archetypes",
"name": "User Archetypes",
"description": "User persona definitions, pain points, and motivations",
"mimeType": "application/json",
},
{
"uri": "knowledge://keywords/research",
"name": "Keyword Research",
"description": "Keyword lists, search volumes, and competition data",
"mimeType": "application/json",
},
]
@server.read_resource()
async def read_resource(uri: str):
"""Read a knowledge resource by URI.
Args:
uri: The resource URI to read.
Returns:
The resource content as JSON.
"""
if uri == "knowledge://app/context":
content = get_app_context()
elif uri == "knowledge://users/archetypes":
content = get_user_archetypes()
elif uri == "knowledge://keywords/research":
content = get_keyword_research()
else:
raise ValueError(f"Unknown resource URI: {uri}")
return content