Skip to content

nixihz/recutils-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Recutils MCP Server (Go Version)

High-performance recutils database MCP (Model Context Protocol) tool implemented in Go, providing type-safe operations.

About Recutils

GNU Recutils is a lightweight text-based database toolkit that stores structured data in plain text files. Key features include:

  • Human-readable - Data stored in plain text format, easy to read and edit
  • Typed records - Supports multiple record types, similar to tables in relational databases
  • Powerful queries - Provides SQL-like query language (recsel)
  • Serverless - No database server process required, zero dependencies
  • VCS-friendly - Text format naturally supports Git and other version control tools

✨ Features

  • βœ… High Performance - Compiled language, 2x faster startup, 50% less memory usage
  • βœ… Type Safety - Compile-time checking, fewer runtime errors
  • βœ… Simple Deployment - Single binary file (~7.3MB), no runtime environment required
  • βœ… Concurrency Support - goroutine provides better concurrency performance
  • βœ… Complete Functionality - Support for query, insert, update, delete, and get database info
  • βœ… MCP Protocol - Complies with Model Context Protocol standard

πŸš€ Quick Start

System Requirements

  • Go 1.21+ (for development)
  • recutils tool package (for runtime)
# Install recutils
# Ubuntu/Debian
sudo apt-get install recutils

# macOS
brew install recutils

Installation

Option 1: Using go install (Recommended)

# Install directly to GOBIN
go install github.com/nixihz/recutils-mcp@latest

# The binary will be installed to $GOBIN (default: ~/go/bin)
# Add to PATH if needed:
export PATH=$PATH:$(go env GOBIN)

# Run the server
recutils-mcp

Option 2: Build from source

# 1. Clone the repository
git clone https://github.com/nixihz/recutils-mcp.git
cd recutils-mcp

# 2. Install dependencies
go mod download

# 3. Run tests
make test

# 4. Build project
make build

# 5. Run server
./recutils-mcp

πŸ”§ Integration with Claude Desktop

Add the following configuration to Claude Desktop's config file:

{
  "mcpServers": {
    "recutils": {
      "command": "$(go env GOBIN)/recutils-mcp",
      "args": []
    }
  }
}

Note: Replace $(go env GOBIN)/recutils-mcp with the actual path if you installed it elsewhere. On macOS/Linux with go install, the default path is ~/go/bin/recutils-mcp.

πŸ“‹ Available Commands

make all           # Run tests and build
make test          # Run all tests
make test-cover    # Run tests with coverage
make build         # Build binary
make clean         # Clean build files
make fmt           # Format code
make vet           # Static check
make bench         # Benchmark test
make security      # Security check
make help          # Show help

πŸ”§ MCP Tools List

Tool Name Description Parameters
recutils_query Query records database_file, query_expression (optional), output_format (optional)
recutils_insert Insert record database_file, record_type, fields
recutils_update Update records database_file, query_expression, fields
recutils_delete Delete records database_file, query_expression
recutils_info Get database info database_file

πŸ“– Usage Examples

Create Database and Insert Data

# 1. Start server
./recutils-mcp

# 2. Call tools via MCP client (Example JSON)

# Query records
{
  "method": "tools/call",
  "params": {
    "name": "recutils_query",
    "arguments": {
      "database_file": "example.rec",
      "query_expression": "Name = 'John Doe'"
    }
  }
}

# Insert records
{
  "method": "tools/call",
  "params": {
    "name": "recutils_insert",
    "arguments": {
      "database_file": "example.rec",
      "record_type": "Person",
      "fields": {
        "Name": "John Doe",
        "Age": 25,
        "City": "New York"
      }
    }
  }
}

Direct Go API Usage

package main

import (
    "context"
    "fmt"
    "github.com/nixihz/recutils-mcp/recutils"
)

func main() {
    ctx := context.Background()
    op := recutils.NewRecordOperation()

    // Insert record
    result, err := op.InsertRecord(ctx, "test.rec", "Person", map[string]interface{}{
        "Name": "John Doe",
        "Age":  25,
    })
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Printf("Insert successful: %+v\n", result)

    // Query records
    queryResult, err := op.QueryRecords(ctx, "test.rec", "", "")
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Printf("Query result: %+v\n", queryResult)
}

πŸ“ Project Structure

recutils-mcp/
β”œβ”€β”€ go.mod                    # Go module definition
β”œβ”€β”€ main.go                   # Main entry point
β”œβ”€β”€ README.md                 # Project documentation (this file)
β”œβ”€β”€ Makefile                  # Build script
β”œβ”€β”€ build.sh                  # Build script
β”œβ”€β”€ .gitignore                # Git ignore file
β”œβ”€β”€ recutils/
β”‚   └── operations.go        # recutils operations encapsulation
└── server/
    β”œβ”€β”€ mcp_server.go        # MCP server implementation
    └── mcp_server_test.go   # Test code

πŸ” Correct File Format

recutils database files must follow specific format:

%rec: Person

Name: John Doe
Age: 25
City: New York

Name: Jane Smith
Age: 30

Format requirements:

  • %rec: must be followed by a blank line
  • Field format: field_name: value
  • Records must be separated by blank lines
  • Important: Records must end with newline (fixed)

πŸ§ͺ Testing

# Run all tests
go test ./... -v

# Run specific test
go test -run TestMCPServer -v

# Test coverage
go test ./... -cover

# Benchmark test
go test -bench=. ./...

Test Results

=== RUN   TestMCPServer
--- PASS: TestMCPServer (0.04s)
    βœ“ QueryRecords
    βœ“ GetDatabaseInfo
    βœ“ InsertRecord
    βœ“ VerifyInsert

=== RUN   TestMCPServerIntegration
--- PASS: TestMCPServerIntegration (0.05s)
    βœ“ FullWorkflow

PASS

πŸ› Troubleshooting

1. Server won't start

Check if recutils is installed:

recsel --version

2. Permission issues

Ensure database files have read/write permissions:

chmod 644 database.rec

3. File format errors

Use recsel to verify file format:

recsel your_database.rec

πŸ“š More Resources

🀝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

πŸ“„ License

MIT License

🏷️ Version History

  • v1.0.0 - Initial release
    • Go language refactoring
    • Full MCP protocol support
    • Fixed database file format issues
    • 2x performance improvement

Recommended for production use! πŸš€

About

Go implementation of MCP server for recutils database operations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages