MA

morinokami/astro-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

61 stars 1 forks 质量 66 趋势 13MIT

MCP服务器支持Astro项目开发

概览

MCP服务器支持Astro项目开发,灵感来自antfu的nuxt-mcp。 该软件套装处于实验阶段且不稳定。使用时请谨慎使用。 Astro-MCP旨在帮助模型更好地理解你的天文项目,通过提供仅凭项目文件无法轻松获取的信息,例如: - 关于 Astro 服务器的运行时信息 - 最新的 Astro 文档内容 - 关于您所使用的 Astro 集成的信息 在您的 Astro 项目目录中,执行以下命令: 然后,将astro-mcp集成添加到你的Astro配置中: 安装集成后,MCP 服务器将在 http://localhost:4321/__mcp/sse. 处开放。连接时,请在编辑器或工具的适当位置创建一个空配置文件: Astro-MCP 会在 Astro 服务器启动时自动更新文件。

概述(AI 翻译)

MCP服务器支持Astro项目开发,灵感来自antfu的nuxt-mcp。

[!重要] 此包装处于实验阶段且不稳定。使用时请谨慎使用。

astro-mcp 旨在帮助模型更好地理解你的天文项目,通过提供仅凭项目文件无法轻松获取的信息,例如:

  • 关于Astro服务器的运行时信息
  • 最新的天文文档内容
  • 关于您所使用的Astro集成的信息

安装

在您的 Astro 项目目录中,执行以下命令:

手动安装

首先,安装 astro-mcp 包:

然后,在你的Astro配置中添加astro-mcp集成:

用途

安装集成后,MCP 服务器将在 [http://localhost:4321/__mcp/sse. 提供连接。连接时,请在编辑器或工具的适当位置创建一个空配置文件:

编辑器/工具 配置文件
VSCode .vscode/mcp.json
光标 .cursor/mcp.json
风帆冲浪 ~/.codeium/windsurf/mcp_config.json
克劳德代码 .mcp.json

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

astro-mcp

MCP server to support Astro project development, inspired by antfu’s nuxt-mcp.

[!IMPORTANT] This package is experimental and unstable. Proceed with caution when using it.

astro-mcp aims to help models understand your Astro project better, by providing them with information that cannot be easily accessed just by looking at the project files, such as:

  • Runtime information about the Astro server
  • Up-to-date Astro docs content
  • Information about the Astro integrations you are using

Installation

In your Astro project directory, run the following command:

npx astro add astro-mcp

Manual installation

First, install the astro-mcp package:

npm install astro-mcp

Then, add the astro-mcp integration to your Astro config:

import { defineConfig } from "astro/config";

import mcp from "astro-mcp";

export default defineConfig({
  integrations: [mcp()],
});

Usage

After installing the integration, the MCP server will be available at http://localhost:4321/__mcp/sse. To connect, create an empty configuration file in the appropriate location for your editor or tool:

Editor/Tool Configuration File
VSCode .vscode/mcp.json
Cursor .cursor/mcp.json
Windsurf ~/.codeium/windsurf/mcp_config.json
Claude Code .mcp.json

astro-mcp will automatically update the file when the Astro server starts.

Extending the MCP server

astro-mcp provides a hook called mcp:setup that other integrations can use to extend the MCP server. This is useful if you want to add custom tools to the MCP server.

export default function createExampleIntegration(): AstroIntegration {
  return {
    name: "example-integration",
    hooks: {
      "mcp:setup": async ({ mcp }) => {
        mcp.tool("add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({
          content: [{ type: "text", text: String(a + b) }],
        }));
      },
    },
  };
}

Tools

  • get-astro-config: Get the Astro config object containing comprehensive project settings including file paths (root, src, public, output directories), site URL, build options, server settings, enabled integrations, markdown processing configuration, image handling, Vite plugins, security settings, and experimental features
    • Parameters: None
  • list-astro-routes: List detailed routing information from your Astro project, including all routes with their file entrypoints, URL patterns, dynamic parameters, pre-rendering status, and route types. Optionally filter by type to focus on specific route categories
    • Parameters:
      • type (string, optional): redirect, page, endpoint, or fallback
在 GitHub 查看完整 README

安装

npx astro add astro-mcp
新手?先看 mcpskill.org 教程 →