Commit Graph

24 Commits

Author SHA1 Message Date
David Dworken
29c69e6a47 Fix uncaught exception in MCP server (#822) 2025-06-09 17:03:15 -07:00
ihrpr
70014a2bbb Support for http request injection propagation to tools (#816) 2025-05-28 15:59:14 +01:00
Marshall Roch
7901552eba send errors to pending requests if server closes (#333)
Co-authored-by: ihrpr <inna@anthropic.com>
2025-05-27 22:55:27 +01:00
ihrpr
5d33861cad Add progress notification callback for client (#721) 2025-05-15 17:45:58 +01:00
Akshey D
9e66f7ce89 feat: add message to ProgressNotification (#435)
Co-authored-by: ihrpr <inna.hrpr@gmail.com>
2025-05-13 18:40:15 +01:00
ihrpr
c6fb822c86 Fix streamable http sampling (#693) 2025-05-12 18:31:35 +01:00
ihrpr
74f5fcfa0d StreamableHttp - client refactoring and resumability support (#595) 2025-05-02 14:49:50 +01:00
ihrpr
cf8b66b82f use metadata from SessionMessage to propagate related_request_id (#591) 2025-05-02 14:35:17 +01:00
ihrpr
da0cf22355 Wrap JSONRPC messages with SessionMessage for metadata support (#590) 2025-05-02 14:29:00 +01:00
ihrpr
78f0b11a09 StreamableHttp - Server transport with state management (#553) 2025-05-02 11:58:54 +01:00
bhosmer-ant
82bd8bc1d9 Properly clean up response streams in BaseSession (#515) 2025-05-01 14:45:47 +01:00
Guillaume Raille
96e5327110 add a timeout arguments on per-request basis (as per MCP specifications) (#601) 2025-04-29 13:58:48 +01:00
David Soria Parra
568cbd1a66 Fix #201: Move incoming message stream from BaseSession to ServerSession (#325)
Co-authored-by: Claude <noreply@anthropic.com>
2025-03-24 14:14:14 +00:00
Marcelo Trylesinski
ae77772ea8 Add strict mode to pyright (#315)
* Add strict mode to pyright

* Apply UP rule

* fix readme

* More correct

* Leave wrong Context for now

* Add strict mode to pyright

* Apply UP rule

* fix readme

* fix

* ignore
2025-03-20 09:13:08 +00:00
Marcelo Trylesinski
7196604468 Revert "refactor: reorganize message handling for better type safety and clar…" (#282)
This reverts commit 9d0f2daddb.
2025-03-14 09:50:46 +00:00
David Soria Parra
9d0f2daddb refactor: reorganize message handling for better type safety and clarity (#239)
* refactor: improve typing with memory stream type aliases

Move memory stream type definitions to models.py and use them throughout
the codebase for better type safety and maintainability.

GitHub-Issue:#201

* refactor: move streams to ParsedMessage

* refactor: update test files to use ParsedMessage

Updates test files to work with the ParsedMessage stream type aliases
and fixes a line length issue in test_201_client_hangs_on_logging.py.

Github-Issue:#201

* refactor: rename ParsedMessage to MessageFrame for clarity

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: move MessageFrame class to types.py for better code organization

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* fix pyright

* refactor: update websocket client to use MessageFrame

Modified the websocket client to work with the new MessageFrame type,
preserving raw message text and properly extracting the root JSON-RPC
message when sending.

Github-Issue:#204

* fix: use NoneType instead of None for type parameters in MessageFrame

🤖 Generated with [Claude Code](https://claude.ai/code)

* refactor: rename root to message
2025-03-13 13:44:55 +00:00
Marcelo Trylesinski
94d326dbf1 Close unclosed resources in the whole project (#267)
* Close resources

* Close all resources

* Update pyproject.toml

* Close all resources

* Close all resources

* try now...

* try to ignore this

* try again

* try adding one more..

* try now

* try now

* revert ci changes
2025-03-13 10:59:45 +00:00
David Soria Parra
78fc5c12c0 fix: fix ci 2025-03-12 14:22:30 +00:00
Marcelo Trylesinski
3e0ab1e7ee Drop AbstractAsyncContextManager for proper type hints (#257) 2025-03-11 13:17:15 +00:00
David Soria Parra
733db0c9cf fix: enforce context manager usage for RequestResponder 2025-02-04 20:13:26 +00:00
David Soria Parra
08cfbe522a fix: improve error handling and request cancellation for issue #88 2025-02-04 18:20:17 +00:00
David Soria Parra
827e494df4 feat: add request cancellation and in-flight request tracking
This commit adds support for request cancellation and tracking of
in-flight requests in the MCP protocol implementation. The key
architectural changes are:

1. Request Lifecycle Management:
   - Added _in_flight dictionary to BaseSession to track active requests
   - Requests are tracked from receipt until completion/cancellation
   - Added proper cleanup via on_complete callback

2. Cancellation Support:
   - Added CancelledNotification handling in _receive_loop
   - Implemented cancel() method in RequestResponder
   - Uses anyio.CancelScope for robust cancellation
   - Sends error response on cancellation

3. Request Context:
   - Added request_ctx ContextVar for request context
   - Ensures proper cleanup after request handling
   - Maintains request state throughout lifecycle

4. Error Handling:
   - Improved error propagation for cancelled requests
   - Added proper cleanup of cancelled requests
   - Maintains consistency of in-flight tracking

This change enables clients to cancel long-running requests and
servers to properly clean up resources when requests are cancelled.

Github-Issue:#88
2025-02-03 20:50:05 +00:00
David Soria Parra
37f6a3229c fix: use pydantic Field with alias for _meta fields
Pydantic treats fields starting with underscore as private/hidden. To fix this,
we need to use Field with alias='_meta' to properly handle these fields while
keeping the external API unchanged. This fixes #103 where meta fields were not
being properly assigned in request contexts.
2024-12-21 23:16:24 +00:00
David Soria Parra
ed87ae9f06 rename mcp_python to mcp 2024-11-11 12:40:32 +00:00