Skip to content

feat(core): MCP Server - Capture prompt results from prompt function calls - #17284

Merged
AbhiPrasad merged 13 commits into
developfrom
bete/mcp-server-prompt-results
Aug 6, 2025
Merged

feat(core): MCP Server - Capture prompt results from prompt function calls#17284
AbhiPrasad merged 13 commits into
developfrom
bete/mcp-server-prompt-results

Conversation

@betegon

@betegonbetegon commented Aug 1, 2025

Copy link
Copy Markdown
Member

closes#17283

includes these attributes for mcp.server spans:

  • mcp.prompt.result.description
  • mcp.prompt.result.message_content
  • mcp.prompt.result.message_role
  • mcp.prompt.result.message_count

Example:
Screenshot 2025-08-01 at 12 40 46

Needed to make attributeExtraction.ts <300 lines of code (requirement) so it's now split between sessionExtraction.ts, sessionExtraction.ts and resultExtraction.ts.

So changes explained so it's easier to review:

  • The only function this PR adds is extractPromptResultAttributes inside resultExtraction.ts.
  • It adds the prompt results as PII in piiFiltering.ts. Just add them to the set.
  • adds a else if (method === 'prompts/get') to execute the extractPromptResultAttributes function.
  • adds a test that checks we're capturing the results and updates the PII test to check PII result attributes are being removed if sending PII is not enabled.

@betegonbetegon self-assigned this Aug 1, 2025
@betegon

Copy link
Copy Markdown
MemberAuthor

@sentry review

Comment threadpackages/core/src/integrations/mcp-server/attributeExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/attributeExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/sessionExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/resultExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/resultExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/resultExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/resultExtraction.ts Outdated
Comment threadpackages/core/src/integrations/mcp-server/resultExtraction.ts Outdated
@betegon
betegon marked this pull request as ready for review August 5, 2025 18:31
@betegon
betegon requested a review from AbhiPrasadAugust 5, 2025 18:31

@AbhiPrasadAbhiPrasad left a comment

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.

awesome

cursor[bot]

This comment was marked as outdated.

@AbhiPrasad

AbhiPrasad commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

feel free to merge @betegon (make sure you squash and merge). Also if we need this backported to v9 you'll need to cherry-pick the commit and open it against the v9 branch.

@AbhiPrasad
AbhiPrasad merged commit 0e05a40 into developAug 6, 2025
184 checks passed
@AbhiPrasad
AbhiPrasad deleted the bete/mcp-server-prompt-results branch August 6, 2025 15:19
@AbhiPrasad

Copy link
Copy Markdown
Contributor

actually whatever I'll just do it 😄

@betegon

Copy link
Copy Markdown
MemberAuthor

thanks @AbhiPrasad . I'm on PTO this week so it's been a bit difficult to keep up 😆

RulaKhaled pushed a commit that referenced this pull request Aug 7, 2025
…calls (#17284)
closes#17283
includes these attributes for `mcp.server` spans:
- `mcp.prompt.result.description`
- `mcp.prompt.result.message_content`
- `mcp.prompt.result.message_role`
- `mcp.prompt.result.message_count`
Example: <img width="835" height="300" alt="Screenshot 2025-08-01 at 12 40 46"
src="https://github.com/user-attachments/assets/592d876b-807a-4f3e-a9b2-406e10f5a83d"
/>
Needed to make `attributeExtraction.ts` <300 lines of code (requirement)
so it's now split between `sessionExtraction.ts`, `sessionExtraction.ts`
and `resultExtraction.ts`.
So changes explained so it's easier to review:
- The only function this PR adds is `extractPromptResultAttributes`
inside `resultExtraction.ts`.
- It adds the prompt results as PII in `piiFiltering.ts`. Just add them
to the `set`.
- adds a `else if (method === 'prompts/get')` to execute the
`extractPromptResultAttributes` function.
- adds a test that checks we're capturing the results and updates the
PII test to check PII result attributes are being removed if sending PII
is not enabled.
betegon added a commit that referenced this pull request Aug 13, 2025
…calls (#17284)
closes#17283
includes these attributes for `mcp.server` spans:
- `mcp.prompt.result.description`
- `mcp.prompt.result.message_content`
- `mcp.prompt.result.message_role`
- `mcp.prompt.result.message_count`
Example:
<img width="835" height="300" alt="Screenshot 2025-08-01 at 12 40 46"
src="https://github.com/user-attachments/assets/592d876b-807a-4f3e-a9b2-406e10f5a83d"
/>
Needed to make `attributeExtraction.ts` <300 lines of code (requirement)
so it's now split between `sessionExtraction.ts`, `sessionExtraction.ts`
and `resultExtraction.ts`.
So changes explained so it's easier to review:
- The only function this PR adds is `extractPromptResultAttributes`
inside `resultExtraction.ts`.
- It adds the prompt results as PII in `piiFiltering.ts`. Just add them
to the `set`.
- adds a `else if (method === 'prompts/get')` to execute the
`extractPromptResultAttributes` function.
- adds a test that checks we're capturing the results and updates the
PII test to check PII result attributes are being removed if sending PII
is not enabled.
(cherry picked from commit 0e05a40)
andreiborza pushed a commit that referenced this pull request Aug 13, 2025
Sign up for freeto 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.

MCP Server - capture prompt results from prompt function calls

2 participants

@betegon@AbhiPrasad