Commit Graph

414 Commits

Author SHA1 Message Date
arthrod
e334f7e4b6 Update __init__.py (#335) 2025-03-20 17:20:40 +00:00
Tom Sheffler
c3fd34a1a6 Enhancement: make stderr of server subprocess configurable (#191)
* make stderr of server subprocess configurable

* Update stdio.py

---------

Co-authored-by: David Soria Parra <167242713+dsp-ant@users.noreply.github.com>
2025-03-20 16:28:57 +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
Niraj Fonseka
5a54d82459 fixing the imports for the prompts example (#318) 2025-03-19 14:42:45 +00:00
Samuel Colvin
805fb469f5 add cwd to StdioServerParameters (#292) 2025-03-19 12:03:10 +00:00
ihrpr
08f4e01b8f add callback for logging message notification (#314) 2025-03-19 09:40:08 +00:00
comfuture
a9aca20205 Option to mount SSE server to existing ASGI server (#312)
* Option to mount SSE server to existing ASGI server

Fixes #311

Add option to mount SSE server to an existing ASGI server.

* Add a new method `sse_app` in `src/mcp/server/fastmcp/server.py` to return an instance of the SSE server app.
* Update the `run_sse_async` method in `src/mcp/server/fastmcp/server.py` to use the new `sse_app` method.
* Update the documentation in `README.md` to include instructions on how to mount the SSE server to an existing ASGI server.
* Fix the example in `README.md` to use `app.mount('/', mcp.sse_app())` instead.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/modelcontextprotocol/python-sdk/issues/311?shareId=XXXX-XXXX-XXXX-XXXX).

* Add `sse_app` method and update `run_sse_async` method in `server.py`

* Add `sse_app` method to return an instance of the SSE server app
* Update `run_sse_async` method to use the new `sse_app` method

Update `README.md` to include instructions for mounting SSE server

* Add section on mounting the SSE server to an existing ASGI server

* fix: Move import statements to the top of the file/

* docs: Update README to reflect changes in mounting SSE server with Starlette

* docs: Formatting of SSE server mounting example in README
2025-03-19 05:26:49 +01:00
Marcelo Trylesinski
6b6f34eaa6 Improve readability of CLI help option (#295) 2025-03-17 10:24:26 +00:00
Marcelo Trylesinski
c8978681f6 Avoid double JSON encoding/decoding (#287) 2025-03-14 15:08:11 +00:00
Samuel Colvin
3775916c5c lint docs examples (#286)
* lint docs examples

* format
2025-03-14 11:30:57 +00:00
Marcelo Trylesinski
97201cce59 Strict types on the client side (#285) 2025-03-14 10:56:48 +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
john0312
ebb81d3b2b Update README to clarify installing mcp to project vs running mcp (#277)
uv add is for adding dependency to uv managed python projects, and folks
not familiar with uv may mistaken the command for running mcp. Added
wordings that clarifies this.
2025-03-13 14:35:53 +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
Michaelzag
ad7f7a5473 Changed default log level to error (#258) 2025-03-13 13:16:21 +00:00
Marcelo Trylesinski
1669a3af01 Release on GitHub release (#276) 2025-03-13 13:09:18 +00:00
Mariusz Woloszyn
5c9f688d95 Add support for Linux configuration path in get_claude_config_path (#270)
* feat: add support for Linux configuration path in get_claude_config_path

* On Linux use XDG_CONFIG_HOME environment variable and fall back to $HOME/.config

* update Linux config path to include 'Claude' directory

* fix: format

---------

Co-authored-by: David Soria Parra <davidsp@anthropic.com>
2025-03-13 11:46:06 +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
Jerome
1691b905e2 Merge pull request #179 from smithery-ai/patch-1
Create Client websocket.py
2025-03-12 22:53:22 +00:00
Henry Mao
fb7d0c8dac Pyright 2025-03-12 13:56:05 -07:00
Henry Mao
ba184a2667 Ruff 2025-03-12 13:51:35 -07:00
Henry Mao
2bcca39aae Update lock 2025-03-12 13:51:35 -07:00
Marcelo Trylesinski
e756315dea Add ServerSessionT type var to Context (#271)
* Add ServerSessionT type var to Context

* Passing locally

* Try now
2025-03-12 15:35:15 +00:00
David Soria Parra
78fc5c12c0 fix: fix ci 2025-03-12 14:22:30 +00:00
Jerome
d51726a9e8 Merge branch 'main' into patch-1 2025-03-12 09:31:56 +00:00
Marcelo Trylesinski
3e0ab1e7ee Drop AbstractAsyncContextManager for proper type hints (#257) 2025-03-11 13:17:15 +00:00
Marcelo Trylesinski
5cbea24ecb Use proper generic for Context (#245) 2025-03-11 13:15:07 +00:00
David Soria Parra
06e692ba5c fix: fix the name of the env variable 2025-03-11 10:26:38 +00:00
Henry Mao
dec28830b9 Remove try except 2025-03-08 10:53:56 +08:00
Henry Mao
ea8a2dbd6d Reraise exception and make websocket optional 2025-03-08 10:52:10 +08:00
Henry Mao
9d65e5ac03 Remove optional check 2025-03-07 22:02:16 +08:00
Henry Mao
fd826cc7a6 Fix Websocket Client and Add Test 2025-03-07 22:00:56 +08:00
Henry Mao
fc021eea76 Apply suggestions from code review
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2025-03-06 20:12:51 +08:00
Henry Mao
f67c3ee6c0 Merge branch 'modelcontextprotocol:main' into patch-1 2025-03-06 13:24:01 +08:00
David Soria Parra
775f879813 bump version 2025-02-20 21:40:35 +00:00
David Soria Parra
b1942b31c4 Fix #177: Returning multiple tool results (#222)
* feat: allow lowlevel servers to return a list of resources

The resource/read message in MCP allows of multiple resources
to be returned. However, in the SDK we do not allow this. This
change is such that we allow returning multiple resource in
the lowlevel API if needed. However in FastMCP we stick to
one, since a FastMCP resource defines the mime_type in the decorator
and hence a resource cannot dynamically return different mime_typed resources.
It also is just the better default to only return one resource.
However in the lowlevel API we will allow this.

Strictly speaking this is not a BC break since the new return value
is additive, but if people subclassed server, it will break them.

* feat: lower the type requriements for call_tool to Iterable
2025-02-20 21:31:26 +00:00
Jerome
2628e01f4b Merge pull request #217 from modelcontextprotocol/jerome/fix/request-context-typing
Updated typing on request context for the server to use server session
2025-02-20 11:07:54 +00:00
David Soria Parra
a50cf92d3a fix: ruff format 2025-02-20 11:04:46 +00:00
David Soria Parra
10a85e452d fix: mark test as pytest.mark.anyio 2025-02-20 11:04:29 +00:00
Jerome
ff22f48365 Add client handling for sampling, list roots, ping (#218)
Adds sampling and list roots callbacks to the ClientSession, allowing the client to handle requests from the server.

Co-authored-by: TerminalMan <84923604+SecretiveShell@users.noreply.github.com>
Co-authored-by: David Soria Parra <davidsp@anthropic.com>
2025-02-20 10:49:43 +00:00
Randall Nortman
106619967b Force stdin/stdout encoding to UTF-8
The character encoding of the stdin/stdout streams in Python is platform-
dependent. On Windows it will be something weird, like CP437 or CP1252,
depending on the locale. This change ensures that no matter the platform,
UTF-8 is used.
2025-02-18 11:23:24 +00:00
Justin Spahr-Summers
5480f67cf9 Merge pull request #207 from hmwildermuth/main
Update URL validation to allow file and other nonstandard schemas
2025-02-13 23:05:59 +00:00
Henry Wildermuth
b53e090299 Update URL validation to allow file and other nonstandard schemas 2025-02-13 14:58:58 -08:00
David Soria Parra
faf3a9d7d6 Merge pull request #205 from modelcontextprotocol/issue-192-request-id-test
Add test to verify request ID preservation
2025-02-13 15:10:00 +00:00
David Soria Parra
92ba4f41d0 Merge pull request #206 from modelcontextprotocol/jerome/fix/188
Jerome/fix/188
2025-02-13 15:09:42 +00:00
David Soria Parra
fbf4acc679 fix: method ordering 2025-02-13 14:54:53 +00:00
Jerome
da53a97ed9 Made message handling concurrent 2025-02-13 14:53:08 +00:00
Jerome
9abfe775cc Added failing test 2025-02-13 14:46:57 +00:00
Jerome
0b5644723b Added ignore revs (for gitlense) 2025-02-13 14:46:57 +00:00
Jerome
e4503a72c8 Added scratch/ to gitignore 2025-02-13 14:46:57 +00:00