Commit Graph

46 Commits

Author SHA1 Message Date
David Soria Parra
bd742272ab fix: update types to reflext 2024-11-05 schema 2025-01-24 09:52:16 +00:00
David Soria Parra
0cb3b26514 Merge pull request #157 from micpst/async-resources
feat: add async resources for FastMCP
2025-01-22 13:37:41 +00:00
Michał Pstrąg
c184b7a8db fix fastmcp logger debug 2025-01-18 19:59:51 +01: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
Salman Mohammed
135191403a Add instructions field to InitializeResult 2025-01-13 11:58:43 -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
a77aaa79a4 refactor: use built-in typing.Annotated instead of typing_extensions 2025-01-06 10:47:44 +00:00
David Soria Parra
e8dd39f839 fix: #128 fix package in the generated mcp run config
During `mcp install` we are generating a config
that relies on `mcp run`. However `mcp` is only available
as a CLI command if we use the `cli` feature.

We need to specify that we want to install mcp
with the cli feature.

Fixes #128
2025-01-06 10:37:01 +00:00
David Soria Parra
58bc32e559 merge: Resolve conflicts from v1.1.x merge 2025-01-03 16:06:51 +00:00
David Soria Parra
e21e8c157d style: Fix import sorting and update ruff version 2025-01-03 15:57:14 +00:00
David Soria Parra
d93b99e163 Merge pull request #121 from allenporter/mcp-sse-type-error
Fix SSE server uncaught TypeError due to incorrect routing
2025-01-03 14:38:58 +00:00
David Soria Parra
ae73191b3e fix: Change --env-var short flag from -e to -v to avoid conflict with --with-editable 2025-01-02 16:57:53 +00:00
David Soria Parra
bd5170e19e Merge pull request #120 from SecretiveShell/fix-encoding-errors
add text encoding params to STDIO client
2025-01-02 14:59:36 +00:00
Allen Porter
b89cabc7df fix: Add constructor for McpError to allow setting field
Backport of #116 by @allenporter to v1.1.x branch.

Fixes an issue where exception handling code fails with AttributeError
when accessing the error field of McpError.
2025-01-02 09:32:43 +00:00
restlessronin
3de4dc1f13 feat: add version string parameter to Server constructor 2025-01-02 09:11:07 +00:00
restlessronin
34a257147b chore: revert doc changes 2025-01-02 09:11:07 +00:00
restlessronin
937c640f04 feat: add version string parameter to 'create_initialization_options' 2025-01-02 09:11:07 +00:00
Allen Porter
247aec9332 Update paths in examples 2024-12-30 10:09:42 -08:00
Allen Porter
1134421a3a Fix inconsistencies in examples 2024-12-30 10:08:57 -08:00
Allen Porter
0970ef4ae0 Fix SSE server bug with uncaught TypeError 2024-12-30 10:04:19 -08:00
TerminalMan
99727a97ae ruff format 2024-12-29 17:09:18 +00:00
TerminalMan
4f36581a5c add text encoding params to STDIO client 2024-12-29 16:41:30 +00:00
samefarrar
e65404aa05 fix: Install still runs the fastmcp command, which is now unecessary (/not installed). We can just run it with mcp. 2024-12-29 15:01:25 +00:00
David Soria Parra
59fff69c38 Merge pull request #106 from modelcontextprotocol/davidsp/fastmcp
feat: Integrate FastMCP
2024-12-23 16:00:53 +00:00
David Soria Parra
52e69efa6f Fix deprecation warning 2024-12-21 23:16:25 +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
0b09fa5944 fix type issues 2024-12-21 00:46:37 +00:00
David Soria Parra
a79f51f55f style: Fix imports and line length formatting 2024-12-21 00:46:36 +00:00
David Soria Parra
87cee0ff33 feat: Add CLI package 2024-12-21 00:41:58 +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
David Soria Parra
1d4a0d3589 ruff format 2024-12-12 17:01:00 +00:00
David Soria Parra
ef9b4cf6a2 Remove click dependency in client 2024-12-12 16:41:30 +00:00
David Soria Parra
587dbb739d Add handler for resource templates
We missed to have a handler for resource templates. We add this
now. One caveat is still that the `uriTemplate` in `ResourceTemplate`
is not a pydantic type.
2024-11-27 23:01:11 +00:00
Justin Spahr-Summers
c6d3bdce0f Fix experimental capabilities example
See discussion in https://github.com/modelcontextprotocol/specification/pull/65.
2024-11-26 08:28:03 -06:00
David Soria Parra
873f6bf03e Merge pull request #62 from modelcontextprotocol/davidsp/error-fixes
Handle MCPErrors separately
2024-11-25 14:15:06 +00:00
David Soria Parra
33f0e590c8 Add a simple module documentation to help LLMs with the pattern
LLMs have issue infering the actual usage pattern from the code
itself. We add a simple module documentation to help with that.
2024-11-25 13:56:38 +00:00
David Soria Parra
f7e47f39c2 Correct comment 2024-11-22 22:54:35 +00:00
David Soria Parra
afe1c0913a When any handler raises an McpError, we pass it as a response 2024-11-22 22:54:35 +00:00
David Soria Parra
07d3b2fca5 fix return values of tools 2024-11-20 11:24:18 +00:00
David Soria Parra
76a0b80c4c feat: add client capability checking to ServerSession
Add methods to track and verify client capabilities during initialization. This
includes storing client parameters from the initialize request and providing a
check_client_capability method to verify if specific capabilities are supported
by the connected client.
2024-11-11 21:53:34 +00:00
David Soria Parra
1177a11910 Return a specific server session instance of request context
We currently return a generic instance of RequestContext without
a specialization on the Session type. This makes it impossible
for servers to typesafe call `list_roots()` and other methods.

We now return a specific instance of `RequestContext[ServerSession]`
2024-11-11 21:11:13 +00:00
David Soria Parra
ec8c85edea run ruff 2024-11-11 20:42:46 +00:00
David Soria Parra
b9b44e6dad Don't re-export types
We will be a bit more low level and expect callees to import mcp.types
instead of relying in re-exported types. This makes usage more explicit
and avoids potential collisions in mcp.server.
2024-11-11 20:39:33 +00:00
David Soria Parra
f5d82bd229 Remove helper types
The helper types in mcp.server.types got really confusioning during
implementation as they overlapped with mcp.types. I now believe it
is better if we stay more low level to the spec types.

To do this, we now only use mcp.types everywhere. We renamed mcp.server.types
to mcp.server.models and removed it to the absolute minimum.
2024-11-11 20:05:51 +00:00
David Soria Parra
ed87ae9f06 rename mcp_python to mcp 2024-11-11 12:40:32 +00:00