chore: switch to module ESNext + moduleResolution bundler (#2095)
This commit is contained in:
parent
c59dc3aa1a
commit
ee732d64b6
16 changed files with 668 additions and 863 deletions
|
|
@ -15,6 +15,7 @@
|
|||
"@modelcontextprotocol/client": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/tsconfig": "workspace:^",
|
||||
"@types/node": "^24.10.1",
|
||||
"typescript": "catalog:devTools"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,8 @@ class MCPClient {
|
|||
messages,
|
||||
});
|
||||
|
||||
finalText.push(followUp.content[0].type === 'text' ? followUp.content[0].text : '');
|
||||
const firstBlock = followUp.content[0];
|
||||
finalText.push(firstBlock?.type === 'text' ? firstBlock.text : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,13 +157,14 @@ class MCPClient {
|
|||
|
||||
//#region main
|
||||
async function main() {
|
||||
if (process.argv.length < 3) {
|
||||
const serverScriptPath = process.argv[2];
|
||||
if (!serverScriptPath) {
|
||||
console.log('Usage: node build/index.js <path_to_server_script>');
|
||||
return;
|
||||
}
|
||||
const mcpClient = new MCPClient();
|
||||
try {
|
||||
await mcpClient.connectToServer(process.argv[2]);
|
||||
await mcpClient.connectToServer(serverScriptPath);
|
||||
|
||||
// Check if we have a valid API key to continue
|
||||
const apiKey = process.env.ANTHROPIC_API_KEY;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
{
|
||||
"extends": "@modelcontextprotocol/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"declaration": false,
|
||||
"declarationMap": false,
|
||||
"types": ["node"],
|
||||
"paths": {
|
||||
"@modelcontextprotocol/client": ["./node_modules/@modelcontextprotocol/client/src/index.ts"],
|
||||
"@modelcontextprotocol/client/stdio": ["./node_modules/@modelcontextprotocol/client/src/stdio.ts"],
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@
|
|||
"prepack": "pnpm run build:esm && pnpm run build:cjs",
|
||||
"lint": "eslint src/ && prettier --ignore-path ../../.prettierignore --check .",
|
||||
"lint:fix": "eslint src/ --fix && prettier --ignore-path ../../.prettierignore --write .",
|
||||
"check": "pnpm run typecheck && pnpm run lint",
|
||||
"start": "pnpm run server",
|
||||
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
|
||||
"client": "tsx scripts/cli.ts client"
|
||||
"check": "pnpm run typecheck && pnpm run lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/client": "workspace:^",
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import {
|
|||
} from '@modelcontextprotocol/client';
|
||||
import open from 'open';
|
||||
|
||||
import { InMemoryOAuthClientProvider } from './simpleOAuthClientProvider.js';
|
||||
import { InMemoryOAuthClientProvider } from './simpleOAuthClientProvider';
|
||||
|
||||
// Set up OAuth (required for this example)
|
||||
const OAUTH_CALLBACK_PORT = 8090; // Use different port than auth server (3001)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import type { ListToolsRequest, OAuthClientMetadata } from '@modelcontextprotoco
|
|||
import { Client, StreamableHTTPClientTransport, UnauthorizedError } from '@modelcontextprotocol/client';
|
||||
import open from 'open';
|
||||
|
||||
import { InMemoryOAuthClientProvider } from './simpleOAuthClientProvider.js';
|
||||
import { InMemoryOAuthClientProvider } from './simpleOAuthClientProvider';
|
||||
|
||||
// Configuration
|
||||
const DEFAULT_SERVER_URL = 'http://localhost:3000/mcp';
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
"zod": "catalog:runtimeShared"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/tsconfig": "workspace:^",
|
||||
"@types/node": "^24.10.1",
|
||||
"typescript": "catalog:devTools"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
{
|
||||
"extends": "@modelcontextprotocol/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"declaration": false,
|
||||
"declarationMap": false,
|
||||
"types": ["node"],
|
||||
"paths": {
|
||||
"@modelcontextprotocol/server": ["./node_modules/@modelcontextprotocol/server/src/index.ts"],
|
||||
"@modelcontextprotocol/server/stdio": ["./node_modules/@modelcontextprotocol/server/src/stdio.ts"],
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@
|
|||
"prepack": "pnpm run build:esm && pnpm run build:cjs",
|
||||
"lint": "eslint src/ && prettier --ignore-path ../../.prettierignore --check .",
|
||||
"lint:fix": "eslint src/ --fix && prettier --ignore-path ../../.prettierignore --write .",
|
||||
"check": "pnpm run typecheck && pnpm run lint",
|
||||
"start": "pnpm run server",
|
||||
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
|
||||
"client": "tsx scripts/cli.ts client"
|
||||
"check": "pnpm run typecheck && pnpm run lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/node-server": "catalog:runtimeServerOnly",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import type { Request, Response } from 'express';
|
|||
import express from 'express';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
import { InMemoryEventStore } from './inMemoryEventStore.js';
|
||||
import { InMemoryEventStore } from './inMemoryEventStore';
|
||||
|
||||
// Create an MCP server with implementation details
|
||||
const getServer = () => {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import cors from 'cors';
|
|||
import type { Request, Response } from 'express';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
import { InMemoryEventStore } from './inMemoryEventStore.js';
|
||||
import { InMemoryEventStore } from './inMemoryEventStore';
|
||||
|
||||
// Check for OAuth flag
|
||||
const useOAuth = process.argv.includes('--oauth');
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { McpServer } from '@modelcontextprotocol/server';
|
|||
import cors from 'cors';
|
||||
import type { Request, Response } from 'express';
|
||||
|
||||
import { InMemoryEventStore } from './inMemoryEventStore.js';
|
||||
import { InMemoryEventStore } from './inMemoryEventStore';
|
||||
|
||||
// Create a fresh MCP server per client connection to avoid shared state between clients
|
||||
const getServer = () => {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@
|
|||
"lint:fix": "eslint src/ --fix && prettier --ignore-path ../../.prettierignore --write .",
|
||||
"check": "pnpm run typecheck && pnpm run lint",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"start": "pnpm run server",
|
||||
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
|
||||
"client": "tsx scripts/cli.ts client"
|
||||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "workspace:^",
|
||||
|
|
@ -54,7 +51,6 @@
|
|||
"eslint-config-prettier": "catalog:devTools",
|
||||
"eslint-plugin-n": "catalog:devTools",
|
||||
"prettier": "catalog:devTools",
|
||||
"tsx": "catalog:devTools",
|
||||
"typescript": "catalog:devTools",
|
||||
"typescript-eslint": "catalog:devTools",
|
||||
"vitest": "catalog:devTools"
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import cors from 'cors';
|
|||
import type { Request, Response as ExpressResponse, Router } from 'express';
|
||||
import express from 'express';
|
||||
|
||||
import type { DemoAuth } from './auth.js';
|
||||
import { createDemoAuth, DEMO_USER_CREDENTIALS } from './auth.js';
|
||||
import type { DemoAuth } from './auth';
|
||||
import { createDemoAuth, DEMO_USER_CREDENTIALS } from './auth';
|
||||
|
||||
export interface SetupAuthServerOptions {
|
||||
authServerUrl: URL;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Auth configuration
|
||||
export type { CreateDemoAuthOptions, DemoAuth } from './auth.js';
|
||||
export { createDemoAuth } from './auth.js';
|
||||
export type { CreateDemoAuthOptions, DemoAuth } from './auth';
|
||||
export { createDemoAuth } from './auth';
|
||||
|
||||
// Auth server setup + demo token verifier (pass to `requireBearerAuth` from @modelcontextprotocol/express)
|
||||
export type { SetupAuthServerOptions } from './authServer.js';
|
||||
export { createProtectedResourceMetadataRouter, demoTokenVerifier, getAuth, setupAuthServer } from './authServer.js';
|
||||
export type { SetupAuthServerOptions } from './authServer';
|
||||
export { createProtectedResourceMetadataRouter, demoTokenVerifier, getAuth, setupAuthServer } from './authServer';
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import type { CreateDemoAuthOptions } from '../src/auth.js';
|
||||
import { createDemoAuth } from '../src/auth.js';
|
||||
import type { CreateDemoAuthOptions } from '../src/auth';
|
||||
import { createDemoAuth } from '../src/auth';
|
||||
|
||||
describe('createDemoAuth', () => {
|
||||
const validOptions: CreateDemoAuthOptions = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue