You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cdf58f1
Browse filesBrowse the repository at this point in the historyBrowse files
Nitish Agarwal
committed
feat: implement daily publish rate limiting with atomic operations (modelcontextprotocol#21)
Implements daily rate limiting for server publications to prevent abuse and ensure
fair usage of the registry. Publishers are limited to a configurable number of
server publications per day (default: 10).
## Features
- Daily publish limit enforcement (configurable via RATE_LIMIT_PER_DAY)
- Namespace-based isolation for rate limiting
- Exemption support with wildcard patterns (e.g., com.anthropic/*)
- Atomic check-and-increment operations to prevent race conditions
- Comprehensive error messages with guidance for limit increases
## Implementation Details
- Added atomic CheckAndIncrementPublishCount to database interface
- PostgreSQL: Uses CTE for atomic check-and-increment operations
- MemoryDB: Uses mutex-based locking for thread safety
- Service layer uses atomic database operations
- Rate limits reset daily at midnight UTC
## Configuration
- RATE_LIMIT_ENABLED: Enable/disable rate limiting (default: true)
- RATE_LIMIT_PER_DAY: Maximum publishes per namespace per day (default: 10)
- RATE_LIMIT_EXEMPTIONS: Comma-separated list of exempt namespaces
## Testing
- Added comprehensive unit tests for service layer
- Added database-level tests for persistence and atomicity
- Concurrent testing verifies exact limit enforcement (no race conditions)
- Tests cover exemptions, time windows, configuration changes
Fixesmodelcontextprotocol#21
0 commit comments