Skip to content

Commit 9f72f10

Browse files
authored
Enhance StreamNative Cloud MCP Server Instructions (#15)
fix #13
1 parent f4cfe22 commit 9f72f10

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

pkg/cmd/mcp/stdio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func newStdioServer(configOpts *ServerOptions, logrusLogger *logrus.Logger) *ser
138138
"streamnative-mcp-server",
139139
"0.0.1",
140140
server.WithResourceCapabilities(true, true),
141-
server.WithInstructions(mcp.GetStreamNativeCloudServerInstructions(userName)),
141+
server.WithInstructions(mcp.GetStreamNativeCloudServerInstructions(userName, snConfig)),
142142
server.WithLogging())
143143

144144
mcp.RegisterPrompts(s)

pkg/mcp/instructions.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@ package mcp
1919

2020
import (
2121
"fmt"
22+
23+
"github.com/streamnative/streamnative-mcp-server/pkg/config"
2224
)
2325

24-
func GetStreamNativeCloudServerInstructions(userName string) string {
26+
func GetStreamNativeCloudServerInstructions(userName string, snConfig *config.SnConfig) string {
27+
contextInformation := ""
28+
if snConfig.Context.PulsarCluster != "" && snConfig.Context.PulsarInstance != "" {
29+
contextInformation = fmt.Sprintf(`
30+
You are currently logged in to StreamNative Cloud with the following context:
31+
- Pulsar Cluster: %s
32+
- Pulsar Instance: %s
33+
`, snConfig.Context.PulsarCluster, snConfig.Context.PulsarInstance)
34+
} else {
35+
contextInformation = `No context is set, use 'sncloud_context_available_clusters' to list the available clusters and 'sncloud_context_use_cluster' to set the context to a specific cluster.
36+
`
37+
}
2538
return fmt.Sprintf(`StreamNative Cloud MCP Server provides resources and tools for AI agents to interact with StreamNative Cloud resources and services.
2639
2740
### StreamNative Cloud API Server Resources
@@ -55,13 +68,14 @@ func GetStreamNativeCloudServerInstructions(userName string) string {
5568
7. **Data Streaming Engine**
5669
- **Concept**: The Data Streaming Engine is the core technology that runs StreamNative Cloud clusters. There are two options: Classic Engine and Ursa Engine.
5770
- **Classic Engine**: The default engine, based on ZooKeeper and BookKeeper, offering low-latency storage suitable for latency-sensitive workloads. It supports Pulsar, Kafka, and MQTT protocols. For Classic Engine, Pulsar protocol will be the default protocol.
58-
- **Ursa Engine**: A next-generation engine based on Oxia and object storage (like S3), providing cost-optimized storage for latency-relaxed scenarios. It currently focuses on Kafka protocol support. For Ursa Engine, you can only uses 'kafka-client-*' or 'kafka-admin-*' tools, do not use 'pulsar-client-*' or 'pulsar-admin-*' tools.
71+
- **Ursa Engine**: A next-generation engine based on Oxia and object storage (like S3), providing cost-optimized storage for latency-relaxed scenarios. It currently focuses on Kafka protocol support. For Ursa Engine, you can only uses 'kafka-client-*' or 'kafka-admin-*' tools, do not use 'pulsar-client-*' or 'pulsar-admin-*' tools on Ursa Engine clusters.
5972
- **Relationship**: The Data Streaming Engine is associated with an instance, determining how clusters within that instance operate and what features they support.
6073
6174
### Protocol-Specific Tools
6275
- When working with **Pulsar protocol resources**, you should only use 'pulsar-admin-*' or 'pulsar-client-*' tools. Do not use 'kafka-client-*' or 'kafka-admin-*' tools for Pulsar protocol operations.
6376
- When working with **Kafka protocol resources**, you should only use 'kafka-client-*' or 'kafka-admin-*' tools. Do not use 'pulsar-admin-*' or 'pulsar-client-*' tools for Kafka protocol operations.
6477
- Using the appropriate protocol-specific tools ensures correct functionality and prevents errors when interacting with different protocol resources.
78+
- Avoid mixing different protocol tools: When working with a specific protocol (Pulsar or Kafka), consistently use only the tools designated for that protocol throughout your entire workflow. Mixing different protocol tools in the same operation sequence may lead to inconsistent behavior, data format incompatibilities, or authentication issues. Always maintain protocol consistency for reliable and predictable results.
6579
6680
### Hierarchical Relationship Summary of Resources
6781
- **Organization** is the top level, containing all other resources.
@@ -71,7 +85,7 @@ func GetStreamNativeCloudServerInstructions(userName string) string {
7185
- **Secrets** belong to an organization and can be shared across instances for securely storing sensitive data.
7286
- **Data Streaming Engine** is associated with an instance, defining the technical architecture and feature support for clusters.
7387
74-
Logged in as %s.`, userName)
88+
Logged in as %s. %s`, userName, contextInformation)
7589
}
7690

7791
func GetExternalKafkaServerInstructions(bootstrapServers string) string {

0 commit comments

Comments
 (0)