A Mastra-powered Model Context Protocol (MCP) server that provides structured access to LayerChart documentation and source code. This server enables AI agents to easily retrieve, search, and understand LayerChart components and examples.
| Mastra Cloud | https://layerchart.mastra.cloud |
Primary choice - Zero cold start, maximum responsiveness. |
|---|
/api/mcp/layerChart/sse for the SSE transport (best for editors that keep long-lived connections)./api/mcp/layerChart/mcp for the HTTP transport (handy for CLIs and quick one-off calls).Mastra Cloud is the recommended deployment for all editors. It offers zero cold start and maximum responsiveness. SSE works best for editors that keep a persistent connection, while HTTP is handy for one-off requests and scripts.
Configure your editor to use the SSE endpoint:
{
"mcpServers": {
"layerchart-docs": {
"url": "https://layerchart.mastra.cloud/api/mcp/layerChart/sse"
}
}
}
Test the MCP connection using mcp-remote or curl:
# Test MCP connection
npx mcp-remote https://layerchart.mastra.cloud/api/mcp/layerChart/mcp
# Check HTTP endpoint
curl -I https://layerchart.mastra.cloud/api/mcp/layerChart/mcp
Once installed, your AI assistant will have access to these tools:
list_docs - List all available documentation pages and component routes from LayerChart.get_doc - Get the documentation content for a specific route. Returns both rendered text and raw source code.get_source - Fetch raw source code for a documentation page (usage) or component implementation (implementation) directly from GitHub.search_docs - Search for documentation and components in the LayerChart repository.After installing the MCP server in your editor, you can ask your AI assistant:
import { MCPClient } from "@mastra/mcp";
const mcp = new MCPClient({
servers: {
layerchart: {
url: "https://layerchart.mastra.cloud/api/mcp/layerChart/sse",
},
},
});
// Get available tools
const tools = await mcp.getTools();
// Call a tool directly
const result = await mcp.callTool("layerchart", "search_docs", {
query: "BarChart",
});
npm install
# or
bun install
npm run dev
# or
bun run dev
npm run build
npm run start
| Script | Description |
|---|---|
dev |
Start Mastra in development mode |
build |
Build the Mastra project for production |
start |
Start the built Mastra server |
src/
āā mastra/
ā āā tools/
ā ā āā getDoc.ts # Hybrid text/code retrieval
ā ā āā getSource.ts # GitHub mapping and fetching logic
ā ā āā listDocs.ts # Sidebar scraping logic
ā ā āā searchDocs.ts # GitHub Search API integration
ā āā index.ts # Mastra configuration
Contributions are welcome! Please follow these guidelines:
MIT