Skip to content

mcp,design: revert 'content' back to an interface type#29

Merged
findleyr merged 1 commit into
mainfrom
findleyr/content
Jun 25, 2025
Merged

mcp,design: revert 'content' back to an interface type#29
findleyr merged 1 commit into
mainfrom
findleyr/content

Conversation

@findleyr

@findleyr findleyr commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

After some experience with the flattened version of Content, we see that
it can easily lead to incorrect usage and is a harder API to read.
Therefore, this CL changes back to a design similar to what we had prior
to https://go.dev/cl/672415, though opting to promote content
unmarshalling to the protocol types that use it, which leads to an
overall simpler api.

@findleyr
findleyr force-pushed the findleyr/content branch 3 times, most recently from 90dec94 to 77f7e59 Compare June 25, 2025 14:25
@jba

jba commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

Truncated commit message.

@findleyr

Copy link
Copy Markdown
Contributor Author

Truncated commit message.

Whoops (I copy-pasted to update the PR description). Fixed. Still getting used to GitHub.

Comment thread design/design.md
Comment thread design/design.md
Comment thread mcp/content.go
Comment thread mcp/content.go Outdated
Comment thread mcp/content.go
Comment thread mcp/content.go Outdated
Comment thread mcp/content.go
Blob []byte `json:"blob,omitempty"` // if nil, then text; else blob
URI string `json:"uri,"`
MIMEType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had talked about using the same interface-plus-concrete-types pattern here, for consistency. Why aren't we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that, and it added a lot of code and complexity for little value. Unlike contents, this isn't a distinguished union: the presence of text or blob determines its type, and otherwise the types are the same. We can make it an interface, but maybe in a later CL?

Comment thread mcp/content.go
Comment thread mcp/content.go
Comment thread mcp/content.go
After some experience with the flattened version of Content, we see that
it can easily lead to incorrect usage and is a harder API to read.
Therefore, this CL changes back to a design similar to what we had prior
to https://go.dev/cl/672415, though opting to promote content
unmarshalling to the protocol types that use it, which leads to an
overall simpler api.
@findleyr
findleyr merged commit 204b594 into main Jun 25, 2025
2 checks passed
@findleyr
findleyr deleted the findleyr/content branch December 7, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants