Skip to content

Commit c57f88a

Browse files
authored
fix: populate Content in toolkit PromptInfos and add JSON proof test (#221)
Portal and knowledge toolkits had Content constants defined but never included them in their PromptInfos() return values, so the platform_info JSON response omitted the content field for toolkit prompts. Add a test that marshals prompt infos to JSON and asserts the content key appears.
1 parent b4f2ff7 commit c57f88a

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

pkg/platform/prompts_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package platform
22

33
import (
44
"context"
5+
"encoding/json"
56
"strings"
67
"testing"
78

@@ -559,6 +560,54 @@ func TestPromptMetadataCollection(t *testing.T) {
559560
}
560561
}
561562

563+
func TestPromptContentInJSON(t *testing.T) {
564+
reg := registry.NewRegistry()
565+
_ = reg.Register(&mockToolkit{kind: "datahub", name: "primary"})
566+
567+
mcpServer := mcp.NewServer(&mcp.Implementation{
568+
Name: "test-server",
569+
Version: "1.0.0",
570+
}, nil)
571+
572+
p := &Platform{
573+
mcpServer: mcpServer,
574+
toolkitRegistry: reg,
575+
config: &Config{
576+
Server: ServerConfig{
577+
Description: "Test.",
578+
Prompts: []PromptConfig{
579+
{
580+
Name: "my-prompt",
581+
Description: "My prompt",
582+
Content: "Do the thing about {topic}.",
583+
Arguments: []PromptArgumentConfig{
584+
{Name: "topic", Description: "The topic", Required: true},
585+
},
586+
},
587+
},
588+
},
589+
},
590+
}
591+
592+
p.registerPlatformPrompts()
593+
594+
infos := p.allPromptInfos()
595+
596+
data, err := json.Marshal(infos)
597+
require.NoError(t, err)
598+
599+
jsonStr := string(data)
600+
assert.Contains(t, jsonStr, `"content"`, "JSON output must include content field")
601+
assert.Contains(t, jsonStr, "Do the thing about {topic}.", "JSON output must include prompt template text")
602+
603+
// Workflow prompts should also have content in the JSON
604+
for _, info := range infos {
605+
if info.Category == "workflow" {
606+
assert.NotEmpty(t, info.Content, "workflow prompt %q must have content", info.Name)
607+
}
608+
}
609+
}
610+
562611
func TestCollectToolkitPromptInfos(t *testing.T) {
563612
reg := registry.NewRegistry()
564613
_ = reg.Register(&mockToolkitWithPrompts{

pkg/toolkits/knowledge/toolkit.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,13 @@ func (*Toolkit) PromptInfos() []registry.PromptInfo {
788788
Name: promptName,
789789
Description: "Guidance on when and how to capture domain knowledge insights",
790790
Category: "toolkit",
791+
Content: knowledgeCapturePrompt,
791792
},
792793
{
793794
Name: userPromptName,
794795
Description: "Record insights from this conversation for data catalog improvement",
795796
Category: "toolkit",
797+
Content: captureKnowledgePromptContent,
796798
},
797799
}
798800
}

pkg/toolkits/portal/toolkit.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,13 @@ func (*Toolkit) PromptInfos() []registry.PromptInfo {
192192
Name: saveAssetPromptName,
193193
Description: "Save an artifact from this conversation as a viewable, shareable asset",
194194
Category: "toolkit",
195+
Content: saveAssetPromptContent,
195196
},
196197
{
197198
Name: showAssetsPromptName,
198199
Description: "Browse your saved artifacts and assets",
199200
Category: "toolkit",
201+
Content: showAssetsPromptContent,
200202
},
201203
}
202204
}

0 commit comments

Comments
 (0)