DaprMcpServer

blogtheristo/DaprMcpServer

3.2

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.

Tools
6
Resources
0
Prompts
0

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:

  1. State Management: Get and set state using Dapr state stores
  2. Service Invocation: Invoke methods on other Dapr services
  3. Pub/Sub Messaging: Publish messages to Dapr pub/sub topics
  4. External Bindings: Invoke external systems through Dapr bindings
  5. Secret Management: Retrieve secrets from Dapr secret stores

Prerequisites

  1. .NET 8.0 or later
  2. Dapr runtime installed and running
  3. Dapr applications configured with appropriate components
  4. 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

  1. Clone or download the project
  2. 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:

  1. Manage distributed state across microservices
  2. Coordinate service interactions in complex workflows
  3. Publish and consume messages for event-driven architectures
  4. Integrate with external systems through bindings
  5. 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 implementation
  • DaprMcpServer.csproj - Project configuration
  • README.md - Documentation

Extending the Server

To add new Dapr capabilities:

  1. Add a new tool definition in HandleToolsList()
  2. Add a case in HandleToolCall()
  3. Implement the handler method following the pattern of existing handlers
  4. 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.