Commit Graph

34 Commits

Author SHA1 Message Date
Akash D
83968b5b2f Handle SSE Disconnects Properly (#612) 2025-05-02 09:32:46 -07:00
ihrpr
78f0b11a09 StreamableHttp - Server transport with state management (#553) 2025-05-02 11:58:54 +01:00
Peter Raboud
2210c1be18 Add support for serverside oauth (#255)
Co-authored-by: David Soria Parra <davidsp@anthropic.com>
Co-authored-by: Basil Hosmer <basil@anthropic.com>
Co-authored-by: ihrpr <inna@anthropic.com>
2025-05-01 19:42:59 +01:00
bhosmer-ant
1a330ac672 Add ToolAnnotations support in FastMCP and lowlevel servers (#482) 2025-04-30 14:52:56 +01:00
Samuel Colvin
697b6e8e05 replace inefficient use of to_jsonable_python (#545) 2025-04-26 20:41:19 +02:00
ihrpr
b4c7db6a50 Format files with ruff (#562) 2025-04-23 05:06:51 +01:00
Dan Lapid
8c9269c34b Move uvicorn import to usage (#502) 2025-04-15 16:51:02 +02:00
David Soria Parra
df2d3a57c2 Fix #355: Fix type error with lifespan context (#368)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2025-03-26 14:18:41 +00:00
Bar Nuri
fd2fd34357 default log level info (#366) 2025-03-25 09:50:15 +00:00
elsejj
e2a7338730 enable custom path of sse server (#246)
Co-authored-by: David Soria Parra <167242713+dsp-ant@users.noreply.github.com>
2025-03-20 17:56:35 +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
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
Michaelzag
ad7f7a5473 Changed default log level to error (#258) 2025-03-13 13:16:21 +00: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
Marcelo Trylesinski
5cbea24ecb Use proper generic for Context (#245) 2025-03-11 13:15:07 +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
4d3e05f6f6 refactor: improve lifespan context typing and documentation
- Add proper generic parameter for lifespan context type
- Update README with TypedDict example for strong typing
- Fix context variable initialization in server
- Improve property return type safety
- Remove redundant documentation
- Ensure compatibility with existing tests
2025-02-13 10:12:59 +00:00
David Soria Parra
d3ea9009b0 feat: add lifespan support to FastMCP server
Adds support for the lifespan API to FastMCP server, enabling:
- Simple setup with FastMCP constructor
- Type-safe context passing to tools and handlers
- Configuration via Settings class
2025-02-11 12:16:44 +00:00
zzstoatzz
ca060014bb centralize type 2025-02-04 11:11:38 -06:00
zzstoatzz
00a44692e7 init 2025-02-04 11:11:38 -06:00
David Soria Parra
5e19c7cf73 Merge pull request #176 from sheffler/fixFirstProgressReport
progress_token is 0 on first tool-call and the return is taken mistakenly
2025-01-30 16:00:01 +00:00
David Soria Parra
53bfac0cc2 fix: make progress_token check E711 compat 2025-01-29 10:01:56 +00:00
Thomas Sheffler
76325b7846 progress_token is 0 on first tool-call and the return is taken mistakenly 2025-01-27 19:04:20 -08:00
David Soria Parra
070e8412c0 refactor: standardize resource response format
Introduce ReadResourceContents type to properly handle MIME types in resource responses. Breaking change in FastMCP read_resource() return type.

Github-Issue:#152
2025-01-27 20:36:10 +00:00
David Soria Parra
8ff4b5e9d3 fix: respect resource mime type in responses
The server was ignoring mime types set on resources, defaulting to text/plain
for strings and application/octet-stream for bytes. Now properly preserves
the specified mime type in both FastMCP and low-level server implementations.

Note that this is breaks backwards compatibility as it changes the return
values of read_resource() on FastMCP. It is BC compatible on lowlevel since
it only extends the callback.

Github-Issue: #152
Reported-by: eiseleMichael
2025-01-27 15:51:44 +00:00
Thomas Sheffler
7a64d8f9af async and await for logging in fastmcp 2025-01-25 07:03:20 -08:00
Michał Pstrąg
f5f19b2361 add support for async resources 2025-01-18 19:37:39 +01:00
Salman Mohammed
bc6746e89b Add instructions field to ServerSession and FastMCP 2025-01-13 13:00:11 -05:00
David Soria Parra
4770bcd0b1 fix: #129 resource template handling in FastMCP server 2025-01-06 20:02:03 +00:00
David Soria Parra
e21e8c157d style: Fix import sorting and update ruff version 2025-01-03 15:57:14 +00:00
Allen Porter
0970ef4ae0 Fix SSE server bug with uncaught TypeError 2024-12-30 10:04:19 -08:00
David Soria Parra
a79f51f55f style: Fix imports and line length formatting 2024-12-21 00:46:36 +00:00
David Soria Parra
557e90d2e7 Integrate FastMCP
This commit integrates FastMCP, a high-level MCP server implementation originally written by Jeremiah Lowin,
into the official MCP SDK. It also updates dependencies and adds new dev dependencies.
It moves the existing SDK into a .lowlevel .
2024-12-21 00:41:38 +00:00