fix: render resource content blocks consistently (#124) (thanks @mvanhorn)
This commit is contained in:
parent
2bd30c235c
commit
e7c6bef1a2
@ -3,6 +3,7 @@
|
||||
## [Unreleased]
|
||||
|
||||
### CLI
|
||||
- Render `resource` content blocks in call output helpers instead of dropping them, including markdown resources and JSON text payloads. (PR #124, thanks @mvanhorn)
|
||||
- Preserve default imports when `mcporter config add` writes a config file, instead of forcing `"imports": []`.
|
||||
- OAuth: avoid crashing on headless Linux when `xdg-open` is unavailable; clear stale dynamic-port client registrations; close callback server if stale-client persistence reads fail. (PR #72, thanks @mgonto)
|
||||
- Added optional `oauthScope`/`oauth_scope` config override as an escape hatch for providers that require explicit scopes.
|
||||
|
||||
@ -120,8 +120,12 @@ function collectCallContent(raw: unknown): CollectedCallContent {
|
||||
const resource = typedEntry.resource as Record<string, unknown> | undefined;
|
||||
if (resource && typeof resource === 'object') {
|
||||
const uri = typeof resource.uri === 'string' ? resource.uri : '';
|
||||
const mimeType = typeof resource.mimeType === 'string' ? resource.mimeType : '';
|
||||
if (typeof resource.text === 'string') {
|
||||
textEntries.push(resource.text);
|
||||
if (mimeType.toLowerCase().includes('markdown')) {
|
||||
markdownEntries.push(resource.text);
|
||||
}
|
||||
const parsed = tryParseJson(resource.text);
|
||||
if (parsed !== null) {
|
||||
jsonCandidates.push(parsed);
|
||||
|
||||
@ -235,6 +235,23 @@ describe('createCallResult resource extraction', () => {
|
||||
expect(result.text()).toBe('# My Project\n\nA description.');
|
||||
});
|
||||
|
||||
it('treats markdown resources as markdown output too', () => {
|
||||
const response = {
|
||||
content: [
|
||||
{
|
||||
type: 'resource',
|
||||
resource: {
|
||||
uri: 'file:///repo/README.md',
|
||||
mimeType: 'text/markdown',
|
||||
text: '# My Project\n\nA description.',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
const result = createCallResult(response);
|
||||
expect(result.markdown()).toBe('# My Project\n\nA description.');
|
||||
});
|
||||
|
||||
it('creates placeholder for binary resource content blocks', () => {
|
||||
const response = {
|
||||
content: [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user