Skip to content

feat: add structured content for response in atlas tools - MCP-374#1288

Merged
dudaschar merged 32 commits into
mainfrom
MCP-374-structuredcontent-atlas
Jul 1, 2026
Merged

feat: add structured content for response in atlas tools - MCP-374#1288
dudaschar merged 32 commits into
mainfrom
MCP-374-structuredcontent-atlas

Conversation

@dudaschar

Copy link
Copy Markdown
Collaborator

Part 3, follow up for #1249

This work enables the output to be provided in structuredContent format which caters for the prompt injection case, but removes the need for additional work on the users side to re-format the output to remove the tags.

This PR apply the updates for the tools inside the atlas package.

Checklist

@dudaschar dudaschar self-assigned this Jun 26, 2026
Comment thread src/tools/atlas/create/createProject.ts Outdated
Comment on lines +159 to +165
const hasAnyRecommendations =
(operations.includes("suggestedIndexes") && hasSuggestedIndexes) ||
(operations.includes("dropIndexSuggestions") && hasDropIndexSuggestions) ||
(operations.includes("slowQueryLogs") && hasSlowQueryLogs) ||
(operations.includes("schemaSuggestions") && hasSchemaSuggestions);

if (!hasAnyRecommendations) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The previous code was always returning true, because even if all recommendations are empty, that's a empty state message in the array.

},
} as const satisfies Record<string, FieldSchema>;

const BuildOutputSchema = {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added this first tool inside /streams, but I'm not sure we should include structured content for this kind of tool cc @nirinchev. I have a draft for the other tools in this folder in case we want to include them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added to the other stream tools

@dudaschar dudaschar marked this pull request as ready for review June 26, 2026 15:28
@dudaschar dudaschar requested a review from a team as a code owner June 26, 2026 15:28
@dudaschar dudaschar requested review from blva and removed request for a team June 26, 2026 15:28
@dudaschar dudaschar requested review from lerouxb and nirinchev June 26, 2026 15:30
Comment thread src/tools/atlas/create/createDBUser.ts Outdated
Comment thread src/tools/atlas/read/listAlerts.ts Outdated
pageNum,
limit,
alerts: [],
totalCount: data?.totalCount ?? 0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is probably the original code rather than your changes and I'm trying to follow this, but how could this ever be > 0? What is data.totalCount if not data.results.length? Or is this paginated? But we're already in the case where length is 0 and there are no alerts. Or is that the unfiltered count and the filter could have just matched 0 but there are more alerts?

@dudaschar dudaschar Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a paginated result, we don't have a filter, but it's possible to request a pageNum bigger than the actual last one with results. In this case, alerts is empty, but totalCount is a valid number.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same the one bellow, I changed to only include totalCount if we have in the response, but since we can still have a valid number while alerts is empty, I'll keep it instead of using 0 straightaway.

Comment thread src/tools/atlas/read/listAlerts.ts Outdated
content: [{ type: "text", text: `Unknown resource type: ${args.resource as string}` }],
isError: true,
};
} as ToolResult<typeof this.outputSchema>;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Casting the output type to be able to not return a structuredContent if is an error.

…tured content for processor and connection states
…uctured content for workspaces, connections, and processors
@dudaschar dudaschar requested a review from lerouxb July 1, 2026 09:17
Comment thread src/tools/atlas/read/listAlerts.ts Outdated
return {
content: formatUntrustedData(
`Found ${alerts.length} alerts with status "${status}" in project ${projectId} (total: ${data.totalCount ?? alerts.length})`,
`Found ${alerts.length} alerts with status "${status}" in project ${projectId} ${data.totalCount && `(total: ${data.totalCount})`}`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just be careful here - you're checking if data.totalCount is truthy so you now leave it off if it is 0 whereas you probably want to include it whenever it is defined.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

that's true, forgot 0 is falsy 😂

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated

@dudaschar dudaschar requested a review from lerouxb July 1, 2026 10:55
@dudaschar dudaschar merged commit 2b080d5 into main Jul 1, 2026
31 of 33 checks passed
@dudaschar dudaschar deleted the MCP-374-structuredcontent-atlas branch July 1, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants