cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
rate_limit.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 [caomengxuan666]
2
3#pragma once
4
5#include <chrono>
6#include <string>
7
9
12
13namespace mcp::server {
14
19 std::string subject;
21 std::string method;
23 std::size_t request_bytes = 0;
24};
25
29 bool allowed = true;
31 std::chrono::milliseconds retry_after{0};
32};
33
41 public:
42 virtual ~RateLimiter() = default;
43
49 const RateLimitRequest& request) = 0;
50};
51
52} // namespace mcp::server
Abstract policy hook for request rate limiting.
Definition rate_limit.hpp:40
virtual core::Result< RateLimitDecision > check(const RateLimitRequest &request)=0
Check whether a request should be admitted.
Shared result and error primitives used by the public cxxmcp SDK.
tl::expected< T, Error > Result
Alias for the SDK result type.
Definition result.hpp:64
Outcome returned by a RateLimiter.
Definition rate_limit.hpp:27
bool allowed
True when the request may proceed.
Definition rate_limit.hpp:29
std::chrono::milliseconds retry_after
Suggested retry delay for rejected requests; zero means unspecified.
Definition rate_limit.hpp:31
Transport-neutral request facts used for rate limit decisions.
Definition rate_limit.hpp:16
std::size_t request_bytes
Approximate serialized request size in bytes, when available.
Definition rate_limit.hpp:23
std::string subject
Subject being limited, typically an authenticated principal or remote address.
Definition rate_limit.hpp:19
std::string method
MCP method name associated with the request.
Definition rate_limit.hpp:21