diff --git a/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts b/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts index 15bd159fe6..c946a9d131 100644 --- a/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts +++ b/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts @@ -55,6 +55,12 @@ describe('IMPORT_ACTIVITIES_PARAMETERS', () => { }); describe('SEARCH_ASSET_PROFILES_PARAMETERS', () => { + it('Refuses a query that contains only spaces', () => { + expect( + SEARCH_ASSET_PROFILES_PARAMETERS.safeParse({ query: ' ' }).success + ).toBe(false); + }); + it(`Refuses a query shorter than ${SEARCH_QUERY_MINIMUM_LENGTH} characters`, () => { expect( SEARCH_ASSET_PROFILES_PARAMETERS.safeParse({ query: 'A' }).success @@ -76,4 +82,10 @@ describe('SEARCH_ASSET_PROFILES_PARAMETERS', () => { ).toBe(true); } }); + + it('Removes spaces at the start and the end of a query', () => { + expect( + SEARCH_ASSET_PROFILES_PARAMETERS.parse({ query: ' Apple ' }).query + ).toBe('Apple'); + }); }); diff --git a/apps/api/src/app/endpoints/mcp/mcp.schemas.ts b/apps/api/src/app/endpoints/mcp/mcp.schemas.ts index 5497a1142c..6a3779c203 100644 --- a/apps/api/src/app/endpoints/mcp/mcp.schemas.ts +++ b/apps/api/src/app/endpoints/mcp/mcp.schemas.ts @@ -81,6 +81,7 @@ export const GET_ACTIVITIES_PARAMETERS = z.object({ export const SEARCH_ASSET_PROFILES_PARAMETERS = z.object({ query: z .string() + .trim() .min(SEARCH_QUERY_MINIMUM_LENGTH) .max(SEARCH_QUERY_MAXIMUM_LENGTH) .describe('The name, symbol or ISIN of the asset profile to find')