mcp-tls

Tool Layer Security for MCP servers and clients

GitHub Stars

0

User Rating

Not Rated

Favorites

0

Views

17

Forks

0

Issues

0

README
MCP-TLS Tool Validation Server
โš ๏ธ This project is in early stage development โš ๏ธ

A lightweight utility server that validates tool definitions for integrity and schema correctness. This server is intended to be used as part of a broader MCP-compatible toolchain but can run independently for testing or CI verification of tool definitions.

๐Ÿ”ง Features
  • ๐Ÿ“ฆ JSON-RPC 2.0-compliant request validation
  • ๐Ÿ” TLS transport support (with optional mTLS enforcement)
  • ๐Ÿ” Tool schema fingerprinting and checksum validation
  • โšก Fast HTTP API built with Chi
  • ๐Ÿงช Unit tested components with Go test support
๐Ÿ“ Project Structure
.
โ”œโ”€โ”€ .github
โ”‚ย ย  โ””โ”€โ”€ workflows/        # CI and release GitHub Actions
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ VERSION
โ”œโ”€โ”€ certs                 # Optional certs directory
โ”œโ”€โ”€ cmd                   # Application entry points
โ”‚ย ย  โ””โ”€โ”€ server/
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ go.sum
โ””โ”€โ”€ pkg
    โ”œโ”€โ”€ config/           # Project configurations
    โ”œโ”€โ”€ logs/             # Log output directory
    โ”œโ”€โ”€ mcp/              # Core MCP-TLS data structures
    โ”œโ”€โ”€ server/           # HTTP server, routes, and handlers
    โ”œโ”€โ”€ tls/              # TLS transport encryption support
    โ”œโ”€โ”€ util/             # JSON helpers
    โ””โ”€โ”€ validate/         # Tool validation logic
๐Ÿš€ Getting Started
Prerequisites
  • Go 1.21+
  • TLS certificate (self-signed or CA-issued)
Configuration

Optional environment variables

Environment Variable Description Required Default s
MCPTLS_SERVER_PORT Port the server listens on No 9090
MCPTLS_SERVER_ADDR Server address No localhost:9090
MCPTLS_LOG_LEVEL Log verbosity level (debug, info, warn) No info
Build and Run a binary
go build -o bin/server ./cmd/server
chmod +x ./bin/server
./bin/server
Build and run with Docker
docker build -t mcp-tls-server .

Run basic with basic configs

docker run --name mcp-tls-server \
  -p 9090:9090 \
  -d \
  mcp-tls-server

Run using docker compose

docker compose up -d
docker compose down
API Endpoints
POST /api/tools/validate

Validates a single tool definition for schema and checksum integrity.

Example

curl -X POST https://localhost:8443/api/tools/validate \
     -H "Content-Type: application/json" \
     -d @tool.json

Example with TLS enabled:

curl -X POST https://localhost:8443/api/tools/validate \
     -H "Content-Type: application/json" \
     --cacert certs/ca.crt \
     --cert certs/client.crt \
     --key certs/client.key \
     -d @tool.json
Request Schema (tool.json)
{
  "name": "example-tool",
  "description": "This tool performs a sample operation.",
  "arguments": {
    "inputA": "value1"
  },
  "parameters": {
    "param1": "value1",
    "param2": 42,
    "param3": true
  },
  "inputSchema": {
    "type": "object",
    "properties": {
      "inputA": {
        "type": "string"
      },
      "inputB": {
        "type": "number"
      }
    },
    "required": ["inputA"]
  },
  "outputSchema": {
    "type": "object",
    "properties": {
      "outputA": {
        "type": "boolean"
      }
    },
    "required": ["outputA"]
  },
  "annotations": {
    "title": "Sample Tool",
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": true,
    "openWorldHint": false
  },
  "secMetaData": {
    "source": "trusted-registry",
    "signature": "abc123signature",
    "public_key_id": "key-456",
    "version": "1.0.0",
    "checksum": "sha256:deadbeef"
  }
}
๐Ÿงช Testing
go test -v ./...
๐Ÿ” TLS Configuration

TLS is mandatory by default.

Supported Flags:
Flag Description
--cert Path to TLS certificate file (PEM format)
--key Path to TLS private key (PEM format)
--ca Path to CA cert for verifying clients
--require-mtls Require client certificate verification
--addr Listen address (default: :8443)