sample-mcp

sample-mcp

0

The Sample MCP Server is designed to connect to a PostgreSQL database, providing features for managing accounts, categories, and transactions. Built with Go and GORM, it supports Docker for development and testing, and uses Mage for build automation.

Overview

A sample MCP (Model Context Protocol) server that connects to a PostgreSQL database. It uses Go with GORM for database operations and PostgreSQL for data storage.

Features

  • Account management (create, read, update, delete)
  • Category management (create, read, update, delete)
  • Transaction tracking (create, read, update, delete)
  • Transaction aggregation (sum, count by account)

Project Structure

  • compose/ - Docker Compose configuration for local development
  • db/ - Database related code
    • entity/ - Data model definitions
    • migrations/ - Database migration scripts
    • repository/ - Data access layer implementations
  • pkg/ - Shared packages and utilities
  • vendor/ - Vendored dependencies

Data Model

  • Account: Represents financial accounts with ID, name, and type
  • Category: Represents transaction categories with ID, name, and type
  • Transaction: Represents financial transactions with amount, date, description, and relationships to accounts and categories

Prerequisites

  • Go 1.24 or higher (as specified in go.mod)
  • Mage build tool
  • Docker and Docker Compose
  • PostgreSQL (or use the provided Docker setup)

Getting Started

Setup with Docker

  1. Clone the repository
  2. Start the PostgreSQL database
  3. Build and run the application

Development Mode

To start the application in development mode:

Testing

  • Running Unit Tests
  • Running Integration Tests

Build Commands

  • mage build - Build the application using GoReleaser
  • mage compilebuild - Build using standard Go build
  • mage test - Run unit tests
  • mage integrationtest - Run integration tests
  • mage lint - Run linter
  • mage dev - Build and start Docker services

Configuration

Configuration File

The application can be configured using a config.yml file. A sample configuration file is provided in config.yml.sample.

Environment Variable

Specify the path to the configuration file using the MCP_SERVER_CONFIG environment variable.

Database Configuration

The PostgreSQL database is configured with default settings for type, host, port, user, password, database, timeout, max idle connections, and max open connections.

License

This project is licensed under the MIT License.