Skip to content
Open
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tableau/mcp-server",
"description": "Helping agents see and understand data.",
"version": "1.18.7",
"version": "1.18.8",
"repository": {
"type": "git",
"url": "git+https://github.com/tableau/tableau-mcp.git"
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function startServer(): Promise<void> {
server.registerRequestHandlers();

const transport = new StdioServerTransport();
await server.connect(transport);
await server.mcpServer.connect(transport);

setNotificationLevel(server, logLevel);
notifier.info(server, `${server.name} v${server.version} running on stdio`);
Expand Down
10 changes: 5 additions & 5 deletions src/logging/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('notification', () => {
const server = new Server();
setNotificationLevel(server, 'debug', { silent: true });
setNotificationLevel(server, 'debug', { silent: true });
expect(server.server.notification).not.toHaveBeenCalled();
expect(server.mcpServer.server.notification).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('notification', () => {

await notifier.info(server, 'test message', { notifier: 'test-logger' });

expect(server.server.notification).toHaveBeenCalledWith(
expect(server.mcpServer.server.notification).toHaveBeenCalledWith(
{
method: 'notifications/message',
params: {
Expand All @@ -141,7 +141,7 @@ describe('notification', () => {

await notifier.debug(server, 'test message', { notifier: 'test-logger' });

expect(server.server.notification).not.toHaveBeenCalled();
expect(server.mcpServer.server.notification).not.toHaveBeenCalled();
});

it('should use server name as default logger', async () => {
Expand All @@ -150,7 +150,7 @@ describe('notification', () => {

await notifier.info(server, 'test message');

expect(server.server.notification).toHaveBeenCalledWith(
expect(server.mcpServer.server.notification).toHaveBeenCalledWith(
{
method: 'notifications/message',
params: {
Expand All @@ -176,7 +176,7 @@ describe('notification', () => {

await notifier.info(server, logMessage, { notifier: 'test-logger' });

expect(server.server.notification).toHaveBeenCalledWith(
expect(server.mcpServer.server.notification).toHaveBeenCalledWith(
{
method: 'notifications/message',
params: {
Expand Down
2 changes: 1 addition & 1 deletion src/logging/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function getSendNotificationMessageFn(level: LoggingLevel) {

// server.sendNotification doesn't provide a way to provide the relatedRequestId
// so we're using server.notification directly.
return server.server.notification(
return server.mcpServer.server.notification(
{
method: 'notifications/message',
params: {
Expand Down
16 changes: 8 additions & 8 deletions src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('server', () => {
const disabledFlags = await Promise.all(allTools.map((tool) => Provider.from(tool.disabled)));
const tools = allTools.filter((_, i) => !disabledFlags[i]);
for (const tool of tools) {
expect(server.registerTool).toHaveBeenCalledWith(
expect(server.mcpServer.registerTool).toHaveBeenCalledWith(
tool.name,
{
description: await Provider.from(tool.description),
Expand All @@ -54,7 +54,7 @@ describe('server', () => {
);
const disabledTools = allDisabledTools.filter((_, i) => disabledToolFlags[i]);
for (const tool of disabledTools) {
expect(server.registerTool).not.toHaveBeenCalledWith(
expect(server.mcpServer.registerTool).not.toHaveBeenCalledWith(
tool.name,
expect.anything(),
expect.anything(),
Expand All @@ -68,7 +68,7 @@ describe('server', () => {
await server.registerTools();

const tool = getQueryDatasourceTool(server, testProductVersion);
expect(server.registerTool).toHaveBeenCalledWith(
expect(server.mcpServer.registerTool).toHaveBeenCalledWith(
tool.name,
{
description: await Provider.from(tool.description),
Expand All @@ -90,13 +90,13 @@ describe('server', () => {
);
for (const [i, tool] of tools.entries()) {
if (tool.name === 'query-datasource' || excludeDisabledFlags[i]) {
expect(server.registerTool).not.toHaveBeenCalledWith(
expect(server.mcpServer.registerTool).not.toHaveBeenCalledWith(
tool.name,
expect.anything(),
expect.anything(),
);
} else {
expect(server.registerTool).toHaveBeenCalledWith(
expect(server.mcpServer.registerTool).toHaveBeenCalledWith(
tool.name,
{
description: await Provider.from(tool.description),
Expand Down Expand Up @@ -128,15 +128,15 @@ describe('server', () => {

it('should register request handlers', async () => {
const server = getServer();
server.server.setRequestHandler = vi.fn();
server.mcpServer.server.setRequestHandler = vi.fn();
server.registerRequestHandlers();

expect(server.server.setRequestHandler).toHaveBeenCalled();
expect(server.mcpServer.server.setRequestHandler).toHaveBeenCalled();
});
});

function getServer(): InstanceType<typeof Server> {
const server = new Server();
server.registerTool = vi.fn();
server.mcpServer.registerTool = vi.fn();
return server;
}
35 changes: 19 additions & 16 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const userAgent = `${serverName}/${serverVersion}`;

export type ClientInfo = InitializeRequest['params']['clientInfo'];

export class Server extends McpServer {
export class Server {
readonly mcpServer: McpServer;
readonly name: string;
readonly version: string;

Expand All @@ -41,22 +42,24 @@ export class Server extends McpServer {
private readonly _clientInfo: ClientInfo | undefined;

get clientInfo(): ClientInfo | undefined {
return this._clientInfo ?? this.server.getClientVersion();
return this._clientInfo ?? this.mcpServer.server.getClientVersion();
}

constructor({ clientInfo }: { clientInfo?: ClientInfo } = {}) {
super(
{
name: serverName,
version: serverVersion,
},
{
capabilities: {
logging: {},
tools: {},
constructor({ clientInfo, mcpServer }: { clientInfo?: ClientInfo; mcpServer?: McpServer } = {}) {
this.mcpServer =
mcpServer ??
new McpServer(
{
name: serverName,
version: serverVersion,
},
},
);
{
capabilities: {
logging: {},
tools: {},
},
},
);

this.name = serverName;
this.version = serverVersion;
Expand Down Expand Up @@ -114,7 +117,7 @@ export class Server extends McpServer {
return tableauToolCallback(args, tableauRequestHandlerExtra);
};

this.registerTool(
this.mcpServer.registerTool(
name,
{
description: await Provider.from(description),
Expand All @@ -127,7 +130,7 @@ export class Server extends McpServer {
};

registerRequestHandlers = (): void => {
this.server.setRequestHandler(SetLevelRequestSchema, async (request) => {
this.mcpServer.server.setRequestHandler(SetLevelRequestSchema, async (request) => {
Comment thread
anyoung-tableau marked this conversation as resolved.
setNotificationLevel(this, request.params.level);
return {};
});
Expand Down
4 changes: 2 additions & 2 deletions src/server/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function startExpressServer({

res.on('close', () => {
transport.close();
server.close();
server.mcpServer.close();
Comment thread
anyoung-tableau marked this conversation as resolved.
});

await connect(server, transport, logLevel, getTableauAuthInfo(req.auth));
Expand Down Expand Up @@ -183,7 +183,7 @@ async function connect(
await server.registerTools(authInfo);
server.registerRequestHandlers();

await server.connect(transport);
await server.mcpServer.connect(transport);
setNotificationLevel(server, logLevel);
}

Expand Down
6 changes: 4 additions & 2 deletions src/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ vi.mock('./server.js', async (importOriginal) => ({
...(await importOriginal()),
Server: vi.fn().mockImplementation(() => ({
name: 'test-server',
server: {
notification: vi.fn(),
mcpServer: {
server: {
notification: vi.fn(),
},
},
})),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ async function getToolResult(): Promise<CallToolResult> {

function getServer(): InstanceType<typeof Server> {
const server = new Server();
server.tool = vi.fn();
server.mcpServer.registerTool = vi.fn();
return server;
}
Loading