Skip to content

Commit f20be12

Browse files
committed
import fixes
1 parent 236e934 commit f20be12

File tree

92 files changed

+1796
-687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1796
-687
lines changed

common/eslint-config/eslint.config.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import eslint from '@eslint/js';
44
import tseslint from 'typescript-eslint';
55
import eslintConfigPrettier from 'eslint-config-prettier/flat';
66
import nodePlugin from 'eslint-plugin-n';
7+
import importPlugin from 'eslint-plugin-import';
78
import { fileURLToPath } from 'node:url';
89
import path from 'node:path';
910

@@ -12,6 +13,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1213
export default tseslint.config(
1314
eslint.configs.recommended,
1415
...tseslint.configs.recommended,
16+
importPlugin.flatConfigs.recommended,
17+
importPlugin.flatConfigs.typescript,
1518
{
1619
languageOptions: {
1720
parserOptions: {
@@ -25,9 +28,21 @@ export default tseslint.config(
2528
plugins: {
2629
n: nodePlugin
2730
},
31+
settings: {
32+
'import/resolver': {
33+
typescript: {
34+
// Let the TS resolver handle NodeNext-style imports like "./foo.js"
35+
// while the actual file is "./foo.ts"
36+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
37+
// Use the tsconfig in each package root (when running ESLint from that package)
38+
project: 'tsconfig.json',
39+
},
40+
},
41+
},
2842
rules: {
2943
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
30-
'n/prefer-node-protocol': 'error'
44+
'n/prefer-node-protocol': 'error',
45+
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
3146
}
3247
},
3348
{

common/eslint-config/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
},
2323
"version": "2.0.0",
2424
"devDependencies": {
25+
"@eslint/js": "^9.39.1",
2526
"eslint": "^9.8.0",
2627
"eslint-config-prettier": "^10.1.8",
28+
"eslint-plugin-import": "^2.32.0",
2729
"eslint-plugin-n": "^17.23.1",
2830
"prettier": "3.6.2",
2931
"typescript": "^5.5.4",
3032
"typescript-eslint": "^8.48.1",
31-
"@eslint/js": "^9.39.1"
33+
"eslint-import-resolver-typescript": "^4.4.4"
3234
}
3335
}

packages/client/src/client/auth-extensions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
import type { CryptoKey, JWK } from 'jose';
9-
import { OAuthClientInformation, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk-core';
10-
import { AddClientAuthentication, OAuthClientProvider } from './auth.js';
9+
import type { OAuthClientInformation, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk-core';
10+
import type { AddClientAuthentication, OAuthClientProvider } from './auth.js';
1111

1212
/**
1313
* Helper to produce a private_key_jwt client authentication function.

packages/client/src/client/auth.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import pkceChallenge from 'pkce-challenge';
2-
import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/sdk-core';
3-
import {
2+
import type {
43
OAuthClientMetadata,
54
OAuthClientInformation,
65
OAuthClientInformationMixed,
76
OAuthTokens,
87
OAuthMetadata,
98
OAuthClientInformationFull,
109
OAuthProtectedResourceMetadata,
11-
OAuthErrorResponseSchema,
1210
AuthorizationServerMetadata,
13-
OpenIdProviderDiscoveryMetadataSchema
11+
FetchLike
1412
} from '@modelcontextprotocol/sdk-core';
1513
import {
14+
LATEST_PROTOCOL_VERSION,
15+
OAuthErrorResponseSchema,
16+
OpenIdProviderDiscoveryMetadataSchema,
1617
OAuthClientInformationFullSchema,
1718
OAuthMetadataSchema,
1819
OAuthProtectedResourceMetadataSchema,
19-
OAuthTokensSchema
20-
} from '@modelcontextprotocol/sdk-core';
21-
import { checkResourceAllowed, resourceUrlFromServerUrl } from '@modelcontextprotocol/sdk-core';
22-
import {
20+
OAuthTokensSchema,
21+
checkResourceAllowed,
22+
resourceUrlFromServerUrl,
2323
InvalidClientError,
2424
InvalidClientMetadataError,
2525
InvalidGrantError,
@@ -28,7 +28,6 @@ import {
2828
ServerError,
2929
UnauthorizedClientError
3030
} from '@modelcontextprotocol/sdk-core';
31-
import { FetchLike } from '@modelcontextprotocol/sdk-core';
3231

3332
/**
3433
* Function type for adding client authentication to token requests.

packages/client/src/client/client.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
import { mergeCapabilities, Protocol, type ProtocolOptions, type RequestOptions } from '@modelcontextprotocol/sdk-core';
2-
import type { Transport } from '@modelcontextprotocol/sdk-core';
3-
4-
import {
1+
import type {
2+
Transport,
3+
ListChangedOptions,
4+
JsonSchemaType,
5+
JsonSchemaValidator,
6+
jsonSchemaValidator,
7+
AnyObjectSchema,
8+
SchemaOutput,
9+
RequestHandlerExtra,
10+
mergeCapabilities,
11+
Protocol,
12+
type ProtocolOptions,
13+
type RequestOptions,
514
type CallToolRequest,
615
CallToolResultSchema,
716
type ClientCapabilities,
@@ -43,27 +52,20 @@ import {
4352
ToolListChangedNotificationSchema,
4453
PromptListChangedNotificationSchema,
4554
ResourceListChangedNotificationSchema,
46-
ListChangedOptions,
4755
ListChangedOptionsBaseSchema,
4856
type ListChangedHandlers,
4957
type Request,
5058
type Notification,
51-
type Result
52-
} from '@modelcontextprotocol/sdk-core';
53-
import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk-core';
54-
import type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator } from '@modelcontextprotocol/sdk-core';
55-
import {
56-
AnyObjectSchema,
57-
SchemaOutput,
59+
type Result,
5860
getObjectShape,
5961
isZ4Schema,
6062
safeParse,
6163
type ZodV3Internal,
6264
type ZodV4Internal
6365
} from '@modelcontextprotocol/sdk-core';
64-
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk-core';
66+
67+
import { AjvJsonSchemaValidator, assertToolsCallTaskCapability, assertClientRequestTaskCapability } from '@modelcontextprotocol/sdk-core';
6568
import { ExperimentalClientTasks } from '../experimental/tasks/client.js';
66-
import { assertToolsCallTaskCapability, assertClientRequestTaskCapability } from '@modelcontextprotocol/sdk-core';
6769

6870
/**
6971
* Elicitation default application helper. Applies defaults to the data based on the schema.

packages/client/src/client/middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { auth, extractWWWAuthenticateParams, OAuthClientProvider, UnauthorizedError } from './auth.js';
2-
import { FetchLike } from '@modelcontextprotocol/sdk-core';
1+
import type { OAuthClientProvider } from './auth.js';
2+
import { auth, extractWWWAuthenticateParams, UnauthorizedError } from './auth.js';
3+
import type { FetchLike } from '@modelcontextprotocol/sdk-core';
34

45
/**
56
* Middleware function that wraps and enhances fetch functionality.

packages/client/src/client/sse.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { EventSource, type ErrorEvent, type EventSourceInit } from 'eventsource';
2-
import { Transport, FetchLike, createFetchWithInit, normalizeHeaders } from '@modelcontextprotocol/sdk-core';
3-
import { JSONRPCMessage, JSONRPCMessageSchema } from '@modelcontextprotocol/sdk-core';
4-
import { auth, AuthResult, extractWWWAuthenticateParams, OAuthClientProvider, UnauthorizedError } from './auth.js';
2+
import type { Transport, FetchLike, JSONRPCMessage } from '@modelcontextprotocol/sdk-core';
3+
import { createFetchWithInit, normalizeHeaders, JSONRPCMessageSchema } from '@modelcontextprotocol/sdk-core';
4+
import type { AuthResult, OAuthClientProvider } from './auth.js';
5+
import { auth, extractWWWAuthenticateParams, UnauthorizedError } from './auth.js';
56

67
export class SseError extends Error {
78
constructor(

packages/client/src/client/stdio.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ChildProcess, IOType } from 'node:child_process';
1+
import type { ChildProcess, IOType } from 'node:child_process';
22
import spawn from 'cross-spawn';
33
import process from 'node:process';
4-
import { Stream, PassThrough } from 'node:stream';
4+
import type { Stream } from 'node:stream';
5+
import { PassThrough } from 'node:stream';
6+
import type { Transport, JSONRPCMessage } from '@modelcontextprotocol/sdk-core';
57
import { ReadBuffer, serializeMessage } from '@modelcontextprotocol/sdk-core';
6-
import { Transport } from '@modelcontextprotocol/sdk-core';
7-
import { JSONRPCMessage } from '@modelcontextprotocol/sdk-core';
88

99
export type StdioServerParameters = {
1010
/**

packages/client/src/client/streamableHttp.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { Transport, FetchLike, createFetchWithInit, normalizeHeaders } from '@modelcontextprotocol/sdk-core';
1+
import type { Transport, FetchLike, JSONRPCMessage } from '@modelcontextprotocol/sdk-core';
22
import {
3+
createFetchWithInit,
4+
normalizeHeaders,
35
isInitializedNotification,
46
isJSONRPCRequest,
57
isJSONRPCResultResponse,
6-
JSONRPCMessage,
78
JSONRPCMessageSchema
89
} from '@modelcontextprotocol/sdk-core';
9-
import { auth, AuthResult, extractWWWAuthenticateParams, OAuthClientProvider, UnauthorizedError } from './auth.js';
10+
import type { AuthResult, OAuthClientProvider } from './auth.js';
11+
import { auth, extractWWWAuthenticateParams, UnauthorizedError } from './auth.js';
1012
import { EventSourceParserStream } from 'eventsource-parser/stream';
11-
import { ReadableWritablePair } from 'node:stream/web';
13+
import type { ReadableWritablePair } from 'node:stream/web';
1214

1315
// Default reconnection options for StreamableHTTP connections
1416
const DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS: StreamableHTTPReconnectionOptions = {

packages/client/src/client/websocket.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Transport } from '@modelcontextprotocol/sdk-core';
2-
import { JSONRPCMessage, JSONRPCMessageSchema } from '@modelcontextprotocol/sdk-core';
1+
import type { Transport, JSONRPCMessage, JSONRPCMessageSchema } from '@modelcontextprotocol/sdk-core';
32

43
const SUBPROTOCOL = 'mcp';
54

0 commit comments

Comments
 (0)