Skip to content

Fix: Barrel file exports #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

KKonstantinov
Copy link
Contributor

Extension to #851 and #511

Motivation and Context

The SDK currently exports from all files, which leads to users/implementors having to import from multiple places from the SDK.

Example:

import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { isInitializeRequest, LoggingLevelSchema, SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js';

This PR introduced index.ts barrel files under the following namespaces:

  • @modelcontextprotocol/sdk/server
  • @modelcontextprotocol/sdk/client
  • @modelcontextprotocol/sdk/shared (a new export added to package.json)

The above snippet would now look like:

import { StreamableHTTPServerTransport, McpServer } from '@modelcontextprotocol/sdk/server';
import { isInitializeRequest, LoggingLevelSchema, SetLevelRequestSchema } from '@modelcontextprotocol/sdk/shared';

How Has This Been Tested?

Unit tests continue to run with no issues.

Breaking Changes

No, it's an improvement and not a breaking change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

There are two files which were a bit controversial "./types.ts", and "./inMemory.ts". These are currently residing at the root level, although they are really "shared". Thus the shared namespace is re-exporting them.

Additionally, the previous client/index.ts contents was moved to client/client.ts and server/index.ts was moved to server/server.ts respectively. Since these two files are now re-exported by the index.ts files, there is no breaking change.

@KKonstantinov
Copy link
Contributor Author

KKonstantinov commented Aug 12, 2025

@cliffhall @ihrpr this is an extension to #851

@cliffhall
Copy link
Member

cliffhall commented Aug 12, 2025

This looks good to me in this view. One important thing for reviewers to do is make certain that the new server.ts and client.ts files contain exactly what their previous index.ts counterparts previously did. This is hard to do in the Files Changed diff view. It will have to be done locally in the IDE comparing to the historical content. I would do this now, but I have to prepare for a meeting.

@ihrpr ihrpr added this to the v2 milestone Aug 18, 2025
@ihrpr
Copy link
Contributor

ihrpr commented Aug 18, 2025

Let's include it in V2

@ihrpr ihrpr mentioned this pull request Aug 18, 2025
@cliffhall
Copy link
Member

Let's include it in V2

@ihrpr maybe we could add a v2-feature label for PRs like this one.

@ihrpr
Copy link
Contributor

ihrpr commented Aug 19, 2025

Let's include it in V2

@ihrpr maybe we could add a v2-feature label for PRs like this one.

I'm marking those PRs with V2 milestone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants