blogtheristo/DaprMcpServer
If you are the rightful owner of DaprMcpServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server that integrates AI models with Dapr capabilities.
Dapr MCP Server
A Model Context Protocol (MCP) server that provides AI models with access to Dapr (Distributed Application Runtime) capabilities.
Features
This MCP server exposes the following Dapr capabilities as MCP tools:
- State Management: Get and set state using Dapr state stores
- Service Invocation: Invoke methods on other Dapr services
- Pub/Sub Messaging: Publish messages to Dapr pub/sub topics
- External Bindings: Invoke external systems through Dapr bindings
- Secret Management: Retrieve secrets from Dapr secret stores
Prerequisites
- .NET 8.0 or later
- Dapr runtime installed and running
- Dapr applications configured with appropriate components
- Dapr is a portable, event-driven runtime that makes it easy for any developer to build resilient, stateless, and stateful applications that run on the cloud and edge and embraces the diversity of languages and developer frameworks.
Dapr codifies the best practices for building microservice applications into open, independent APIs called building blocks. The Dapr building block APIs:
Enable you to build portable applications using the language and framework of your choice.
Are completely independent
Have no limit to how many you use in your application
Using Dapr, you can incrementally migrate your existing applications to a microservices architecture, thereby adopting cloud native patterns such scale out/in, resiliency, and independent deployments.
Dapr is platform agnostic, meaning you can run your applications:
Locally
On any Kubernetes cluster
On virtual or physical machines
In other hosting environments that Dapr integrates with.
This enables you to build microservice applications that can run on the cloud and edge.
Installation
- Clone or download the project
- Build the project:
dotnet build
Usage
Running the MCP Server
The server communicates via stdin/stdout following the MCP protocol:
dotnet run
Configuration
The server connects to Dapr on localhost:3500 by default. You can modify the constructor parameters in Program.cs to change:
- Dapr HTTP port (default: 3500)
- App ID (default: "dapr-mcp-server")
Available Tools
dapr_state_get
Retrieve state from a Dapr state store.
{
"stateStore": "statestore",
"key": "mykey"
}
dapr_state_set
Set state in a Dapr state store.
{
"stateStore": "statestore",
"key": "mykey",
"value": {"data": "example"}
}
dapr_service_invoke
Invoke a method on another Dapr service.
{
"appId": "target-service",
"methodName": "process-data",
"data": {"input": "example"},
"httpVerb": "POST"
}
dapr_pubsub_publish
Publish a message to a Dapr pub/sub topic.
{
"pubsubName": "pubsub",
"topic": "orders",
"data": {"orderId": 123}
}
dapr_binding_invoke
Invoke an external binding through Dapr.
{
"bindingName": "storage",
"operation": "create",
"data": {"filename": "test.txt", "content": "Hello World"}
}
dapr_secrets_get
Retrieve a secret from a Dapr secret store.
{
"secretStore": "secrets",
"key": "database-password"
}
Integration with AI Models
This MCP server can be used with any MCP-compatible AI client (like Claude Desktop) to give AI models the ability to:
- Manage distributed state across microservices
- Coordinate service interactions in complex workflows
- Publish and consume messages for event-driven architectures
- Integrate with external systems through bindings
- Securely access secrets for authentication and configuration
Example Dapr Components
To use this MCP server, you'll need Dapr components configured. Here are example component files:
State Store (Redis)
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
Pub/Sub (Redis)
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
Development
Project Structure
Program.cs- Main entry point and MCP server implementationDaprMcpServer.csproj- Project configurationREADME.md- Documentation
Extending the Server
To add new Dapr capabilities:
- Add a new tool definition in
HandleToolsList() - Add a case in
HandleToolCall() - Implement the handler method following the pattern of existing handlers
- Update the README documentation
Testing
Test the server by running it and sending MCP requests via stdin:
dotnet run
Then send JSON-RPC requests like:
{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
License
This project is open source. Please check the license file for details.