Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import { checkPaidCallTarget, parsePaidCallAllowlist, type PaidCallAllowRule } f
import { fetchWithTimeout } from '../fetch.js';
import { config } from '../config.js';
import { ssrfSafeFetch, SsrfError, type SsrfFetchOptions } from '../net/ssrf.js';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { join, dirname } from 'path';

// Read the version from package.json at startup so it is never out of step
// with the published package. Renamed from 'bazaar-mcp-server' to
// 'lens-mcp-server' to reflect the containing project (client-affecting change).
const _pkgPath = join(dirname(fileURLToPath(import.meta.url)), '../../package.json');
const _pkg = JSON.parse(readFileSync(_pkgPath, 'utf8')) as { version: string };
/** The version string advertised to MCP clients — sourced from package.json. */
export const SERVER_VERSION: string = _pkg.version;
/** The canonical MCP server name advertised to clients. */
export const SERVER_NAME = 'lens-mcp-server';

export interface McpServerConfig {
fetchWithPayment: typeof fetch;
Expand Down Expand Up @@ -49,8 +62,8 @@ export class BazaarMcpServer {
};
this.server = new Server(
{
name: 'bazaar-mcp-server',
version: '1.0.0',
name: SERVER_NAME,
version: SERVER_VERSION,
},
{
capabilities: {
Expand Down
16 changes: 15 additions & 1 deletion tests/mcp.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { describe, it, expect, vi } from 'vitest';
import { BazaarMcpServer } from '../src/mcp/server';
import { BazaarMcpServer, SERVER_VERSION, SERVER_NAME } from '../src/mcp/server';
import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import { readFileSync } from 'fs';
import { join } from 'path';

const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8')) as { version: string };

describe('BazaarMcpServer — server identity', () => {
it('advertises the version from package.json (never a hard-coded string)', () => {
expect(SERVER_VERSION).toBe(pkg.version);
});

it('uses the canonical server name lens-mcp-server (client-affecting rename from bazaar-mcp-server)', () => {
expect(SERVER_NAME).toBe('lens-mcp-server');
});
});

describe('BazaarMcpServer', () => {
it('should map signature expiration ledger error to ERR_EXPIRED_AUTHORISATION', async () => {
Expand Down