Cover image
Try Now
2025-03-22

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

Model Context Protocol (MCP) Server - Filesystem Implementation

This is an educational implementation of a Model Context Protocol (MCP) server in Go using the Echo framework. The server provides access to the local filesystem through the MCP protocol.

Overview

The Model Context Protocol (MCP) is an open standard that enables developers to build secure, two-way connections between their data sources and AI-powered tools. This implementation demonstrates how to create an MCP server that provides access to the local filesystem.

Features

  • Filesystem Provider: Provides access to the local filesystem through MCP tools and resources
  • Tools:
    • filesystem.list: Lists the contents of a directory
    • filesystem.read: Reads the contents of a file
    • filesystem.write: Writes content to a file
    • filesystem.delete: Deletes a file or directory
  • Resources:
    • filesystem.file: Represents a file in the filesystem
    • filesystem.directory: Represents a directory in the filesystem

Security Considerations

This implementation includes basic path sanitization to prevent directory traversal attacks, but it is intended for educational purposes only. In a production environment, additional security measures would be necessary, such as:

  • User authentication and authorization
  • More robust input validation
  • Rate limiting
  • Audit logging
  • Sandboxing

Getting Started

Prerequisites

  • Go 1.24 or higher

Installation

  1. Clone the repository
  2. Install dependencies: go mod tidy
  3. Run the server: go run main.go

The server will start on port 8080 by default. You can change the port by setting the PORT environment variable.

API Endpoints

  • GET /: Server information
  • POST /v1/discover: Discover server capabilities
  • POST /v1/call-tool: Call a tool
  • POST /v1/load-resource: Load a resource

Example Usage

Discover Server Capabilities

curl -X POST http://localhost:8080/v1/discover

List Directory Contents

curl -X POST http://localhost:8080/v1/call-tool \
  -H "Content-Type: application/json" \
  -d '{
    "tool_id": "filesystem.list",
    "request_id": "req-123",
    "params": {
      "arguments": {
        "path": "."
      }
    }
  }'

Read File Contents

curl -X POST http://localhost:8080/v1/call-tool \
  -H "Content-Type: application/json" \
  -d '{
    "tool_id": "filesystem.read",
    "request_id": "req-123",
    "params": {
      "arguments": {
        "path": "README.md"
      }
    }
  }'

License

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

Disclaimer

This implementation is for educational purposes only and should not be used in production environments without proper security review and hardening.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • Lists Tailwind CSS classes in monospaced font

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

    Reviews

    2 (1)
    Avatar
    user_rzLnrSZF
    2025-04-17

    I'm incredibly impressed with the mcp-server-test by Loag. It's a robust and efficient tool for server testing, perfect for developers looking to streamline their processes. The thoughtful design and comprehensive documentation are standout features, making it accessible for both beginners and experts. Highly recommended for anyone in need of reliable server testing solutions! Check it out at https://github.com/Loag/mcp-server-test.