Skip to main content

Development Guide

This document provides a step-by-step guide for contributing to the mcp-golang project. By no means is it complete, but it should help you get started.

Development Setup

To set up your development environment, follow these steps:

Prerequisites

  • Go 1.19 or higher
  • Git

Local Development

  1. Clone the repository:
  1. Install dependencies:
  1. Run tests:

Project Structure

The project is organized into several key packages:
  • server/: Core server implementation
  • transport/: Transport layer implementations (stdio, SSE)
  • protocol/: MCP protocol implementation
  • examples/: Example implementations
  • internal/: Internal utilities and helpers

Implementation Guidelines

Creating a Custom Transport

To implement a custom transport, create a struct that implements the Transport interface. If your transport is not part of the spec then you can add it as an experimental feature. Before you implement the transport, you should have a good understanding of the MCP protocol. Take a look at https://spec.modelcontextprotocol.io/specification/

Testing

Unit Tests

All new functions should have unit tests where possible. We currently use testify for this. Each test should explain its purpose and expected behavior. E.g.

Integration Tests

Run integration tests that use the actual transport layers:

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run existing tests
  6. Submit a pull request

Pull Request Guidelines

  • Keep changes focused and atomic
  • Follow existing code style
  • Include tests for new functionality
  • Update documentation as needed
  • Add yourself to CONTRIBUTORS.md

Adding docs

Prerequisite: Please install Node.js (version 19 or higher) before proceeding.
Follow these steps to install and run Mintlify on your operating system: Step 1: Install Mintlify:
Step 2: Navigate to the docs directory (where the mint.json file is located) and execute the following command:
A local preview of your documentation will be available at http://localhost:3000. When your PR merges into the main branch, it will be deployed automatically.

Getting Help