mcp-postgres 4.0.2

High-performance MCP server for PostgreSQL with CPU-aware connection pooling and optimized buffers
Documentation
[package]
name = "mcp-postgres"
version = "4.0.2"
edition = "2024"
authors = ["Piyush"]
description = "High-performance MCP server for PostgreSQL with CPU-aware connection pooling and optimized buffers"
repository = "https://github.com/corporatepiyush/mcp-pg-rust"
homepage = "https://github.com/corporatepiyush/mcp-pg-rust"
license = "Apache-2.0"
readme = "README.md"
keywords = ["mcp", "postgresql", "database", "server", "json-rpc"]
categories = ["database", "web-programming::http-server"]
include = ["src/", "bin/", "tools.json", "Cargo.toml", "README.md", "schema.sql"]

[dependencies]
# PostgreSQL
tokio = { version = "1.41", features = ["macros", "rt-multi-thread", "io-util", "net", "time", "sync", "io-std"] }
tokio-postgres = { version = "0.7", features = ["with-serde_json-1"] }

# HTTP/2 and SSE
axum = "0.7"
hyper = { version = "1.0", features = ["full"] }
futures = "0.3"
tokio-stream = "0.1"

# JSON-RPC and Protocol
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
lru = "0.12"

# Utilities
uuid = { version = "1.10", features = ["v4"] }
crossbeam = { version = "0.8", features = ["crossbeam-queue"] }
once_cell = "1.20"
fake = { version = "5.1" }
dashmap = "6.0"
parking_lot = "0.12"

# Logging
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }

# Error Handling
thiserror = "1.0"
anyhow = "1.0"

# Metrics
prometheus = { version = "0.13", default-features = false }

# CLI
clap = { version = "4.5", features = ["derive"] }

# Memory Allocator (wraps mimalloc C library - currently v2.1.x with v2 features)
mimalloc = { version = "0.1", features = ["local_dynamic_tls", "extended", "override"] }

# System (TCP socket options, CPU detection)
libc = "0.2"
num_cpus = "1.16"

# HTTP Client for latency testing and data import
reqwest = { version = "0.11", features = ["json"] }

# Binary data for PostgreSQL COPY protocol
bytes = "1.6"

[dev-dependencies]
tokio-test = "0.4"
criterion = "0.5"

# Latest minor version fetches
# Run: cargo update --aggressive

[lints.clippy]
# ── Low-level performance lints ──────────────────────────────────────────────
# These catch allocation, copy, and inlining inefficiencies at compile time.
#
# Notable gaps (no clippy lint exists):
#   - Cache-line false sharing → use `#[repr(align(64))]` discipline (manual)
#   - Branch prediction hints → use `#[cold]` / `#[inline]` (manual)
#   - Memory ordering audit   → `cargo clippy` cannot check Ordering semantics

# Stack / memory layout
large_stack_frames = "warn"        # >2KB stack frames → L1 cache pressure
large_enum_variant = "warn"        # oversized enum variants → wasteful layout
boxed_local = "warn"               # fn(Box<T>) forces heap alloc on caller

# Clone / copy overhead
redundant_clone = "warn"           # unnecessary .clone() on hot path
needless_pass_by_value = "warn"    # large types passed by value → memcpy
trivially_copy_pass_by_ref = "warn" # &u32 vs u32 (extra indirection)

# Const / compile-time evaluation
missing_const_for_fn = "warn"      # missed const → runtime eval instead of compile-time

# Integer conversion waste
cast_lossless = "warn"             # i64 → i32 loses precision without cast
unnecessary_cast = "warn"          # u32 as u32 → dead instruction

# Collection / string inefficiency
vec_init_then_push = "warn"        # Vec::new() + push → use with_capacity
string_add_assign = "warn"         # s = s + x → s.push_str(x) (reallocation)
inefficient_to_string = "warn"     # .to_string() on &str → redundant alloc
manual_memcpy = "warn"             # manual copy loop → use copy_from_slice

# Drop / semantics
# let_underscore_drop — renamed from clippy to rustc; handled via #[allow()] per-site
option_option = "warn"             # Option<Option<T>> → confusing layout

[[bin]]
name = "mcp-postgres"
path = "src/main.rs"

[[bin]]
name = "generate_load"
path = "bin/generate_load.rs"

[[bin]]
name = "batch_load"
path = "bin/batch_load.rs"

[[bin]]
name = "benchmark"
path = "bin/benchmark.rs"

[[bin]]
name = "load_test_data"
path = "bin/load_test_data.rs"

[[bin]]
name = "measure_latency"
path = "bin/measure_latency.rs"

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
strip = true
panic = "abort"
overflow-checks = false

[profile.bench]
inherits = "release"
debug = true