🪪 fix: Misleading MCP Server Lookup Method Name (#11315)

* 🔧 fix: MCP server ID resolver in access permissions (#11315)

- Replaced `findMCPServerById` with `findMCPServerByObjectId` in access permissions route and corresponding tests for improved clarity and consistency in resource identification.

* 🔧 refactor: Update MCP server resource access methods to use server name

- Replaced instances of `findMCPServerById` with `findMCPServerByServerName` across middleware, database, and test files for improved clarity and consistency in resource identification.
- Updated related comments and test cases to reflect the change in method usage.

* chore: Increase timeout for Redis update in GenerationJobManager integration tests

- Updated the timeout duration from 50ms to 200ms in the GenerationJobManager integration tests to ensure reliable verification of final event data in Redis after emitting the done event.
This commit is contained in:
Danny Avila 2026-01-12 21:04:25 -05:00 committed by GitHub
parent a8fa85b8e2
commit f8774983a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 26 additions and 27 deletions

View file

@ -228,22 +228,22 @@ describe('MCPServer Model Tests', () => {
});
});
describe('findMCPServerById', () => {
describe('findMCPServerByServerName', () => {
test('should find server by serverName', async () => {
const created = await methods.createMCPServer({
config: createSSEConfig('Find By Id Test'),
config: createSSEConfig('Find By Name Test'),
author: authorId,
});
const found = await methods.findMCPServerById(created.serverName);
const found = await methods.findMCPServerByServerName(created.serverName);
expect(found).toBeDefined();
expect(found?.serverName).toBe('find-by-id-test');
expect(found?.config.title).toBe('Find By Id Test');
expect(found?.serverName).toBe('find-by-name-test');
expect(found?.config.title).toBe('Find By Name Test');
});
test('should return null when server not found', async () => {
const found = await methods.findMCPServerById('non-existent-server');
const found = await methods.findMCPServerByServerName('non-existent-server');
expect(found).toBeNull();
});
@ -254,7 +254,7 @@ describe('MCPServer Model Tests', () => {
author: authorId,
});
const found = await methods.findMCPServerById('lean-test');
const found = await methods.findMCPServerByServerName('lean-test');
// Lean documents don't have mongoose methods
expect(found).toBeDefined();
@ -621,7 +621,7 @@ describe('MCPServer Model Tests', () => {
expect(deleted?.serverName).toBe('delete-test');
// Verify it's actually deleted
const found = await methods.findMCPServerById('delete-test');
const found = await methods.findMCPServerByServerName('delete-test');
expect(found).toBeNull();
});

View file

@ -134,10 +134,10 @@ export function createMCPServerMethods(mongoose: typeof import('mongoose')) {
/**
* Find an MCP server by serverName
* @param serverName - The MCP server ID
* @param serverName - The unique server name identifier
* @returns The MCP server document or null
*/
async function findMCPServerById(serverName: string): Promise<MCPServerDocument | null> {
async function findMCPServerByServerName(serverName: string): Promise<MCPServerDocument | null> {
const MCPServer = mongoose.models.MCPServer as Model<MCPServerDocument>;
return await MCPServer.findOne({ serverName }).lean();
}
@ -311,7 +311,7 @@ export function createMCPServerMethods(mongoose: typeof import('mongoose')) {
return {
createMCPServer,
findMCPServerById,
findMCPServerByServerName,
findMCPServerByObjectId,
findMCPServersByAuthor,
getListMCPServersByIds,