Skip to content

flydf2/mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Service

This is a generated MCP (Model Context Protocol) service for my-mcp-service.

Overview

A generated MCP service

Directory Structure

  • src/ - Source code
  • docs/ - Documentation
  • bin/ - Binary files

Getting Started

Prerequisites

  • Go 1.24.7 or later

Installation

  1. Clone the repository
  2. Install dependencies:
    cd src
    go mod tidy

Configuration

Copy docs/config.env.example to src/config.env and update the values:

cp docs/config.env.example src/config.env
# Edit src/config.env with your API details

Running the Service

Stdio Mode

cd src
go run main.go

HTTP Mode

cd src
SERVER_MODE=http go run main.go

SSE Mode

cd src
SERVER_MODE=sse go run main.go

Available Tools

  • getPosts: Get list of posts

  • createPost: Create a new post

  • updatePost: Update an existing post

  • deletePost: Delete a post

API Endpoints

  • getPosts: Get list of posts

  • createPost: Create a new post

  • updatePost: Update an existing post

  • deletePost: Delete a post

Build

To build the service:

cd src
go build -o ../bin/mcp-server main.go

Usage

Using the MCP Service

You can use any MCP client to interact with this service. Here's an example using curl:

# Stdio mode
echo '{"toolcall":{"thought":"","name":"getPosts","params":{"page":1,"per_page":10}}}' | ./bin/mcp-server

# HTTP mode
curl -X POST http://localhost:8080/mcp -H "Content-Type: application/json" -d '{"toolcall":{"thought":"","name":"getPosts","params":{"page":1,"per_page":10}}}'

Troubleshooting

Common Issues

  • API connection errors: Check your API_URL and API_KEY in config.env
  • Server mode issues: Ensure SERVER_MODE is set to one of: stdio, http, sse
  • Port conflicts: If port 8080 is in use, change SERVER_PORT in config.env

Logs

The service logs information to the console. For more detailed logs, set the DEBUG environment variable:

DEBUG=true go run main.go

MCP Method Configuration

To use this MCP service with other applications, you can configure it as a tool in your MCP client. Here's an example configuration:

{
  "name": "my-mcp-service",
  "description": "A generated MCP service",
  "tools": [
    
    {
      "name": "getPosts",
      "description": "Get list of posts",
      "parameters": [
        
        {
          "name": "page",
          "type": "integer",
          "required": false,
          "description": "Page number"
        },
        
        {
          "name": "per_page",
          "type": "integer",
          "required": false,
          "description": "Posts per page"
        },
        
      ]
    },
    
    {
      "name": "createPost",
      "description": "Create a new post",
      "parameters": [
        
        {
          "name": "title",
          "type": "string",
          "required": true,
          "description": "Post title"
        },
        
        {
          "name": "content",
          "type": "string",
          "required": true,
          "description": "Post content"
        },
        
        {
          "name": "status",
          "type": "string",
          "required": false,
          "description": "Post status"
        },
        
      ]
    },
    
    {
      "name": "updatePost",
      "description": "Update an existing post",
      "parameters": [
        
        {
          "name": "id",
          "type": "integer",
          "required": true,
          "description": "Post ID"
        },
        
        {
          "name": "title",
          "type": "string",
          "required": false,
          "description": "Post title"
        },
        
        {
          "name": "content",
          "type": "string",
          "required": false,
          "description": "Post content"
        },
        
        {
          "name": "status",
          "type": "string",
          "required": false,
          "description": "Post status"
        },
        
      ]
    },
    
    {
      "name": "deletePost",
      "description": "Delete a post",
      "parameters": [
        
        {
          "name": "id",
          "type": "integer",
          "required": true,
          "description": "Post ID"
        },
        
      ]
    },
    
  ]
}

About

Generated MCP service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages