Skip to main content
Glama
aws-powertools

Powertools MCP Search Server

buildResponse.test.ts1.27 kB
import { expect, it } from 'vitest'; import { buildResponse } from '../../src/tools/shared/buildResponse.ts'; it('builds a response with text and no error', () => { // Prepare const content = 'This is a test response'; // Act const response = buildResponse({ content }); // Assess expect(response.content).toEqual([{ type: 'text', text: content }]); expect(console.debug).toHaveLogged( expect.objectContaining({ message: 'Tool response', content, }) ); }); it('builds a response with text and an error', () => { // Prepare const content = 'This is an error response'; // Act const response = buildResponse({ content, isError: true }); // Assess expect(response.content).toEqual([{ type: 'text', text: content }]); expect(response.isError).toBe(true); expect(console.error).toHaveLogged( expect.objectContaining({ message: 'Tool response indicates an error', content, }) ); }); it('stringifies the text content', () => { // Prepare const content = { message: 'This is a stringified response' }; // Act const response = buildResponse({ content }); // Assess expect(response.content).toEqual([ { type: 'text', text: JSON.stringify(content), }, ]); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aws-powertools/powertools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server