Skip to content

Commit 8baa14b

Browse files
authored
feat(mcp): add dapr mcp client + bump protos (#997)
* feat(mcp): add mcp related classes + bump protos Signed-off-by: Samantha Coyle <sam@diagrid.io> * feat: add ex plus some changes Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: updates on workflow names Signed-off-by: Samantha Coyle <sam@diagrid.io> * chore: bump proto version Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: uv run ruff format Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: bump protos again Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: drop down proto versions Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: address copilot feedback Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: appease linter Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: address albert feedback Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: final round of fixes and things I noticed Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: update for test Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: updates for build to pass for linter/tests Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: address sergio feedback Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: adjust dapr branch version Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: address final feedback Signed-off-by: Samantha Coyle <sam@diagrid.io> --------- Signed-off-by: Samantha Coyle <sam@diagrid.io>
1 parent 7750593 commit 8baa14b

25 files changed

Lines changed: 1843 additions & 47 deletions

dapr/aio/clients/grpc/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
GetMetadataResponse,
8181
GetSecretResponse,
8282
InvokeMethodResponse,
83+
MetadataMCPServer,
8384
QueryResponse,
8485
QueryResponseItem,
8586
RegisteredComponents,
@@ -1726,13 +1727,15 @@ async def get_metadata(self) -> GetMetadataResponse:
17261727
for i in response.registered_components
17271728
]
17281729
extended_metadata = dict(response.extended_metadata.items())
1730+
mcp_servers = [MetadataMCPServer(name=s.name) for s in response.mcp_servers]
17291731

17301732
return GetMetadataResponse(
17311733
application_id=response.id,
17321734
active_actors_count=active_actors_count,
17331735
registered_components=registered_components,
17341736
extended_metadata=extended_metadata,
17351737
headers=await call.initial_metadata(),
1738+
mcp_servers=mcp_servers,
17361739
)
17371740

17381741
async def schedule_job_alpha1(self, job: Job, overwrite: bool = False) -> DaprResponse:

dapr/clients/grpc/_response.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ def __init__(
956956
registered_components: Sequence[RegisteredComponents],
957957
extended_metadata: Dict[str, str],
958958
headers: MetadataTuple = (),
959+
mcp_servers: Optional[Sequence[MetadataMCPServer]] = None,
959960
):
960961
"""Initializes GetMetadataResponse.
961962
@@ -968,12 +969,15 @@ def __init__(
968969
extended_metadata (Dict[str, str]): mapping of custom (extended)
969970
attributes to their respective values.
970971
headers (Tuple, optional): the headers from Dapr gRPC response.
972+
mcp_servers (Sequence[MetadataMCPServer], optional): list of
973+
loaded MCPServer resources.
971974
"""
972975
super().__init__(headers)
973976
self._application_id = application_id
974977
self._active_actors_count = active_actors_count
975978
self._registered_components = registered_components
976979
self._extended_metadata = extended_metadata
980+
self.mcp_servers: Sequence[MetadataMCPServer] = mcp_servers or []
977981

978982
@property
979983
def application_id(self) -> str:
@@ -1012,6 +1016,13 @@ class RegisteredComponents(NamedTuple):
10121016
"""Supported capabilities for this component type and version."""
10131017

10141018

1019+
class MetadataMCPServer(NamedTuple):
1020+
"""Describes a loaded Dapr MCPServer resource."""
1021+
1022+
name: str
1023+
"""Name of the MCPServer resource."""
1024+
1025+
10151026
class CryptoResponse(DaprResponse, Generic[TCryptoResponse]):
10161027
"""An iterable of cryptography API responses."""
10171028

dapr/clients/grpc/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
GetMetadataResponse,
7272
GetSecretResponse,
7373
InvokeMethodResponse,
74+
MetadataMCPServer,
7475
QueryResponse,
7576
QueryResponseItem,
7677
RegisteredComponents,
@@ -1831,13 +1832,15 @@ def get_metadata(self) -> GetMetadataResponse:
18311832
for i in response.registered_components
18321833
]
18331834
extended_metadata = dict(response.extended_metadata.items())
1835+
mcp_servers = [MetadataMCPServer(name=s.name) for s in response.mcp_servers]
18341836

18351837
return GetMetadataResponse(
18361838
application_id=response.id,
18371839
active_actors_count=active_actors_count,
18381840
registered_components=registered_components,
18391841
extended_metadata=extended_metadata,
18401842
headers=call.initial_metadata(),
1843+
mcp_servers=mcp_servers,
18411844
)
18421845

18431846
def set_metadata(self, attributeName: str, attributeValue: str) -> DaprResponse:

dapr/proto/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
## Generating gRPC interface and Protobuf
22

3+
We use [uv](https://docs.astral.sh/uv/) to manage the regen environment.
4+
35
### Linux and MacOS
46

57
Run the following commands:
68

79
```sh
810
uv sync --all-packages --group dev
9-
export DAPR_BRANCH=release-1.17 # Optional, defaults to master
11+
export DAPR_BRANCH=master # Optional, defaults to master
1012
uv run ./tools/regen_grpcclient.sh
1113
```
1214

dapr/proto/runtime/v1/metadata_pb2.py

Lines changed: 40 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)