Epic Stack example with MCP
An Epic Stack example adding support for the Model Context Protocol (MCP).
The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). Think of MCP like a USB-C port for AI applications - it provides a standardized way to connect AI models to different data sources and tools.
Learn more from the MCP Documentation
This repository demonstrates how to integrate MCP into an Epic Stack application. The implementation includes:
app/routes/mcp+/mcp.server.ts
)export const server = new McpServer(
{
name: 'epic-mcp-a25d',
version: '1.0.0',
},
{
capabilities: {
tools: {},
},
},
)
The MCP server is the core component that handles tool registration and execution. It's configured with a unique name and version, and defines the capabilities it provides.
server.tool(
'Find User',
'Search for users in the Epic Notes database by their name or username',
{ query: z.string().describe('The query to search for') },
async ({ query }) => {
// Implementation...
},
)
Tools are the primary way to expose functionality to LLMs. Each tool:
app/routes/mcp+/fetch-transport.server.ts
)The transport layer handles the bi-directional communication between the MCP client and server:
app/routes/mcp+/index.ts
)export async function loader({ request }: Route.LoaderArgs) {
const url = new URL(request.url)
const sessionId = url.searchParams.get('sessionId')
const transport = await connect(sessionId)
return transport.handleSSERequest(request)
}
The Remix route:
Tool Design: When designing tools for LLMs:
State Management: The implementation demonstrates:
Integration Patterns: Learn how to:
Security Considerations: