-
Notifications
You must be signed in to change notification settings - Fork 233
Implement SEP-973 #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Implement SEP-973 #570
Changes from all commits
2b368a3
085099e
970671b
24947b3
ec8b14a
dc32c43
1fb3343
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,19 +135,36 @@ func incTool(_ context.Context, _ *CallToolRequest, args incInput) (*CallToolRes | |
| return nil, incOutput{args.X + 1}, nil | ||
| } | ||
|
|
||
| var iconObj = Icon{Source: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAQKADAAQAAAABAAAAQAAAAABGUUKwAAAJhElEQVRoBb2adaxUOxDGcXd3d3cLgaDBLbgT3N3dAgkuwSE4BAkQNLgGAsGCu7u7894v75Ayb84u2927y/3jZs7Zr9OZdjr9Oj3h/gn935kzZ8aMGRMlSpRw//3Fjh172rRpFy9eDErP4YKixZuSTZs2lSlTxpjuOOD8jx49etWqVXfv3u2treX7UDnw7NmzJk2aSIs9yhEjRuzcufP79+8tzXXDQuLAnTt3Chcu7NFijy8rVKjw8uVLt3E2b4LvwK1bt/LkyaMMjRQpUq5cuapUqVKpUqVs2bKFDx9eAWrUqPH161cbixUmyA5cv349Z86cyrhmzZqdOHHC2Pfp06dDhw7VqlVLwSZNmqSMs3kMpgNXr15ldKVZLN/58+d7s2PcuHFyKhInTvzo0SNvYG/vg+bApUuXsmTJIq2PGjXq8uXLvXXsvO/WrZtsMmXKlD/j3b8Gx4Hz589nzJhRmkKWXL16terv27dvP378kC+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1cJerqwnT1gaLWH+OUDLmTNnun1QpshHdkDZHzJVHcJPYpApsiuY5aPfDqCXWouKJWWN8wg1wltlB/uGKonCkCdOnKhg9o+BOIB2Dpmkf+rSHk2nCMmRnGKEsgOmqEqiHACnTp2qYH49hgft0Qiblyxrqu2UYznyw8mgqxSQixQpwj2AurREG0dTlsrp06eNZkKRz1bcHMkArAS/3A0Y7P7+gLPRnDlzAlZoGgYYQqa9jeCxJEr13KatT0zIHeD7AziSDAaKh4sXL/ZpmSUgtA5Qigzg+wNL0x1YCB1gt1KVDkrFq1at8ss+n+AQOkDNQkYOOcr9/YFP+3wCQuUArFPeI3E16C6J+jTOBuDhMlAOW8AyhwGqVKY5h3f3F07m17AIoXKAcJcVro0bN8JSw2Kot7ahcoBdVp6zoP5cJuCGNzsCf28TZ4FhKDJzqSMtC8U6DtUidnzmQk2RoqBn0tA6gBsev6Vzf40W2CTTKuQO0IebTfCpDkfKgI2WDf+GA/Sn+Bz3ReraStrkl/yXHMAmGLU57HOtryoUfhktwWE60MgMYyNTv+AOge/qqKb4dbD+g/J/AVf65lqU7WK5AAAAAElFTkSuQmCC", | ||
| MIMEType: "image/png", Sizes: []string{"48x48", "96x96"}} | ||
|
|
||
| // runServerTest runs the server conformance test. | ||
| // It must be executed in a synctest bubble. | ||
| func runServerTest(t *testing.T, test *conformanceTest) { | ||
| ctx := t.Context() | ||
| // Construct the server based on features listed in the test. | ||
| s := NewServer(&Implementation{Name: "testServer", Version: "v1.0.0"}, nil) | ||
| impl := &Implementation{Name: "testServer", Version: "v1.0.0"} | ||
|
|
||
| // TODO(IAmSurajBobade): Remove this hack once we have a client protocol specific handling. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove your self assignment here. We'll probably clean up by adding a more general "settings" file to the test archive. |
||
| if test.name == "version-draft.txtar" { | ||
| impl.Icons = []Icon{iconObj} | ||
| impl.WebsiteURL = "https://modelcontextprotocol.io" | ||
| } | ||
|
|
||
| s := NewServer(impl, nil) | ||
| for _, tn := range test.tools { | ||
| switch tn { | ||
| case "greet": | ||
| AddTool(s, &Tool{ | ||
| Name: "greet", | ||
| Description: "say hi", | ||
| }, sayHi) | ||
| case "greetWithIcon": | ||
| AddTool(s, &Tool{ | ||
| Name: "greetWithIcon", | ||
| Description: "say hi", | ||
| Icons: []Icon{iconObj}, | ||
| }, sayHi) | ||
| case "structured": | ||
| AddTool(s, &Tool{Name: "structured"}, structuredTool) | ||
| case "tomorrow": | ||
|
|
@@ -167,6 +184,13 @@ func runServerTest(t *testing.T, test *conformanceTest) { | |
| switch pn { | ||
| case "code_review": | ||
| s.AddPrompt(codeReviewPrompt, codReviewPromptHandler) | ||
| case "code_reviewWithIcon": | ||
| s.AddPrompt(&Prompt{ | ||
| Name: "code_review", | ||
| Description: "do a code review", | ||
| Arguments: []*PromptArgument{{Name: "Code", Required: true}}, | ||
| Icons: []Icon{iconObj}, | ||
| }, codReviewPromptHandler) | ||
| default: | ||
| t.Fatalf("unknown prompt %q", pn) | ||
| } | ||
|
|
@@ -177,6 +201,13 @@ func runServerTest(t *testing.T, test *conformanceTest) { | |
| s.AddResource(resource1, readHandler) | ||
| case "info": | ||
| s.AddResource(resource3, handleEmbeddedResource) | ||
| case "infoWithIcon": | ||
| s.AddResource(&Resource{ | ||
| Name: "info", | ||
| MIMEType: "text/plain", | ||
| URI: "embedded:info", | ||
| Icons: []Icon{iconObj}, | ||
| }, handleEmbeddedResource) | ||
| default: | ||
| t.Fatalf("unknown resource %q", rn) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,10 @@ const ( | |
| // | ||
| // It is the version that the client sends in the initialization request, and | ||
| // the default version used by the server. | ||
| latestProtocolVersion = protocolVersion20250618 | ||
| protocolVersion20250618 = "2025-06-18" | ||
| latestProtocolVersion = protocolVersion20250618 | ||
|
|
||
| protocolVersionDraft = "draft" // draft protocol version with experimental features for testing | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can remove this now, if we're not attempting to gate this functionality on the latest spec. |
||
| protocolVersion20250618 = "2025-06-18" // latest stable version | ||
| protocolVersion20250326 = "2025-03-26" | ||
| protocolVersion20241105 = "2024-11-05" | ||
| ) | ||
|
|
@@ -48,6 +50,12 @@ var supportedProtocolVersions = []string{ | |
| // negotiatedVersion returns the effective protocol version to use, given a | ||
| // client version. | ||
| func negotiatedVersion(clientVersion string) string { | ||
| // If client sends protocol version draft, enable draft features. | ||
| if clientVersion == protocolVersionDraft { | ||
| log.Printf("Using draft protocol version features") | ||
| return protocolVersionDraft | ||
| } | ||
|
|
||
| // In general, prefer to use the clientVersion, but if we don't support the | ||
| // client's version, use the latest version. | ||
| // | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the actual data does not matter, can we please make this "foobar".
I don't want arbitrary, unreviewable data to be checked into the repo (I don't know what this data represents).