design: add design for rate limiting (#36)
I added an example for how rate limiting should be implemented using middleware. Fixes #22 ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> Rate limiting can be enabled using middleware. This adds an example on how to do that. ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> N/A ## Breaking Changes <!-- Will users need to update their code or configurations? --> No ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions -->
This commit is contained in:
parent
032c62c8ad
commit
bc59932176
1 changed files with 74 additions and 0 deletions
|
|
@ -470,6 +470,10 @@ server.AddReceivingMiddleware(withLogging)
|
|||
|
||||
**Differences from mcp-go**: Version 0.26.0 of mcp-go defines 24 server hooks. Each hook consists of a field in the `Hooks` struct, a `Hooks.Add` method, and a type for the hook function. These are rarely used. The most common is `OnError`, which occurs fewer than ten times in open-source code.
|
||||
|
||||
#### Rate Limiting
|
||||
|
||||
Rate limiting can be configured using middleware. Please see [examples/rate-limiting](<https://github.com/modelcontextprotocol/go-sdk/tree/main/examples/rate-limiting>] for an example on how to implement this.
|
||||
|
||||
### Errors
|
||||
|
||||
With the exception of tool handler errors, protocol errors are handled transparently as Go errors: errors in server-side feature handlers are propagated as errors from calls from the `ClientSession`, and vice-versa.
|
||||
|
|
|
|||
Loading…
Reference in a new issue