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. |
|---|
- Append
/api/mcp/layerChart/ssefor the SSE transport (best for editors that keep long-lived connections). - Append
/api/mcp/layerChart/mcpfor the HTTP transport (handy for CLIs and quick one-off calls).
- Route Discovery: List all available documentation and component routes.
- Hybrid Retrieval: Get documentation text from the website combined with raw source code from GitHub.
- Source Access: Fetch raw Svelte source code for both documentation pages (usage) and component implementations.
- Semantic Search: Search across the LayerChart repository to find relevant components and documentation.
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/mcpOnce 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:
- "How do I use the BarChart component in LayerChart?"
- "Show me examples of using tooltips in LayerChart"
- "What are the props for the Axis component?"
- "Find documentation for the PieChart component"
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",
});- Install dependencies:
npm install
# or
bun install- Run in development mode:
npm run dev
# or
bun run dev- Build and run production:
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:
- Fork the repo and create a feature branch
- Follow Conventional Commits for commit messages
- Submit a PR describing your change
MIT