Cosmic MCP Server

Cosmic MCP Server

A production-ready Model Context Protocol server for interacting with Cosmic headless CMS, providing comprehensive tools for managing objects, types, and media in your Cosmic bucket.

Category
访问服务器

README

Cosmic MCP Server

License: MIT Cosmic Build Status Tests Coverage npm version npm downloads

A robust, production-ready Model Context Protocol (MCP) server for interacting with the Cosmic headless CMS. This server provides a comprehensive set of tools for creating, reading, updating, and deleting objects, types, and media in your Cosmic bucket.

✨ Features

  • Comprehensive Toolset: Full CRUD operations for Cosmic objects, object types, and media.
  • Robust Architecture: Built with a clean, three-layer architecture (Server, Services, Repositories).
  • Strongly Typed: Written in TypeScript with strict validation using Zod for all inputs.
  • Production-Ready: Includes centralized logging, rate-limiting, and graceful error handling.
  • Easy to Configure: Simple setup using a .env file for your Cosmic credentials.
  • Extensible: Designed to be easily extended with new tools and services.

🚀 Getting Started

Prerequisites

  • Bun (v1.0 or higher)
  • A Cosmic account and bucket.

1. Installation

Clone the repository and install the dependencies:

git clone https://github.com/patgpt/cosmic-mcp.git
cd cosmic-mcp
bun install

2. Configuration

Copy the example environment file and fill in your Cosmic bucket credentials. You can find these in your Cosmic dashboard under Bucket > Settings > API Keys.

cp .env.example .env

Your .env file should look like this:

# .env
COSMIC_BUCKET_SLUG="your-bucket-slug"
COSMIC_READ_KEY="your-read-key"
COSMIC_WRITE_KEY="your-write-key"
DEBUG="false" # Set to "true" for verbose logging

3. Running the Server

Start the MCP server using the following command:

bun start

The server will connect and be ready to receive requests from any MCP-compatible client.

4. Using with MCP Clients

For VS Code (using Claude Dev extension)

Add this configuration to your VS Code settings or Claude Dev configuration:

{
  "mcp": {
    "servers": {
      "Cosmic": {
        "type": "stdio",
        "command": "npx",
        "args": ["-y", "cosmic-mcp"],
        "env": {
          "COSMIC_BUCKET_SLUG": "your-bucket-slug",
          "COSMIC_READ_KEY": "your-read-key",
          "COSMIC_WRITE_KEY": "your-write-key",
          "DEBUG": "false"
        }
      }
    }
  }
}

For Cursor

Add this configuration to your .cursor/mcp.json file:

{
  "mcpServers": {
    "Cosmic": {
      "command": "npx",
      "args": ["-y", "cosmic-mcp"],
      "env": {
        "COSMIC_BUCKET_SLUG": "your-bucket-slug",
        "COSMIC_READ_KEY": "your-read-key",
        "COSMIC_WRITE_KEY": "your-write-key",
        "DEBUG": "false"
      }
    }
  }
}

Alternative: Local Development

If you're developing locally or prefer to use the local version:

For VS Code:

{
  "mcp": {
    "servers": {
      "Cosmic": {
        "type": "stdio",
        "command": "node",
        "args": ["path/to/cosmic-mcp/dist/server.js"],
        "env": {
          "COSMIC_BUCKET_SLUG": "your-bucket-slug",
          "COSMIC_READ_KEY": "your-read-key",
          "COSMIC_WRITE_KEY": "your-write-key",
          "DEBUG": "true"
        }
      }
    }
  }
}

For Cursor:

{
  "mcpServers": {
    "Cosmic": {
      "command": "node",
      "args": ["path/to/cosmic-mcp/dist/server.js"],
      "env": {
        "COSMIC_BUCKET_SLUG": "your-bucket-slug",
        "COSMIC_READ_KEY": "your-read-key",
        "COSMIC_WRITE_KEY": "your-write-key",
        "DEBUG": "true"
      }
    }
  }
}

Note: Replace your-bucket-slug, your-read-key, and your-write-key with your actual Cosmic bucket credentials. You can find these in your Cosmic dashboard under Bucket > Settings > API Keys.


🛠️ Available Tools

This MCP server exposes the following tools. All tools are designed to be called by an AI agent or other MCP client.

Tool Name Description
list_objects List objects, with optional filtering by type, status, and pagination.
get_object Get a specific object by its ID or by its slug and type.
create_object Create a new object.
update_object Update an existing object.
delete_object Delete an object.
list_object_types List all available object types in the bucket.
search_objects Perform a text-based search across objects.
upload_media Upload a media file.
list_media List all media files, with pagination.
delete_media Delete a media file by its ID.

For detailed input schemas for each tool, please refer to the 📚 Documentation or the src/manifest.ts file.


📚 Documentation

Comprehensive documentation is available at https://patgpt.github.io/cosmic-mcp/

The documentation includes:

Local Documentation

You can also run the documentation locally:

# Install dependencies
npm install

# Start the documentation server
npm run docs:dev

# Build the documentation
npm run docs:build

🧪 Running Tests

This project is set up with tests to ensure reliability.

# Run all tests
bun test

🤝 Contributing

Contributions are welcome! If you have a suggestion or find a bug, please open an issue to discuss it.

Please see our CONTRIBUTING.md for detailed guidelines on how to contribute to this project, including:

  • Development setup and workflow
  • Code style and standards
  • Testing requirements
  • Pull request process
  • Release process

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选