feat(compat): export InMemoryTransport from public API surface (#1834)
Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com>
This commit is contained in:
parent
7d7e62ccc8
commit
42cb6b2b72
4 changed files with 16 additions and 8 deletions
6
.changeset/export-inmemory-transport.md
Normal file
6
.changeset/export-inmemory-transport.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@modelcontextprotocol/server': patch
|
||||
'@modelcontextprotocol/client': patch
|
||||
---
|
||||
|
||||
Export `InMemoryTransport` for in-process testing.
|
||||
|
|
@ -469,22 +469,20 @@ const client = new Client(
|
|||
);
|
||||
```
|
||||
|
||||
### `InMemoryTransport` removed from public API
|
||||
### `InMemoryTransport` moved
|
||||
|
||||
`InMemoryTransport` has been removed from the public API surface. It was previously used for in-process client-server connections and testing.
|
||||
|
||||
For **testing**, import it directly from the internal core package:
|
||||
`InMemoryTransport` is now exported from `@modelcontextprotocol/client` and `@modelcontextprotocol/server` (both re-export it). It is still intended for in-process client-server connections and testing.
|
||||
|
||||
```typescript
|
||||
// v1
|
||||
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
||||
|
||||
// v2 (testing only — @modelcontextprotocol/core is internal, not for production use)
|
||||
import { InMemoryTransport } from '@modelcontextprotocol/core';
|
||||
// v2
|
||||
import { InMemoryTransport } from '@modelcontextprotocol/server';
|
||||
// or
|
||||
import { InMemoryTransport } from '@modelcontextprotocol/client';
|
||||
```
|
||||
|
||||
For **production in-process connections**, use `StreamableHTTPClientTransport` with a local server URL, or connect client and server via paired streams.
|
||||
|
||||
### Removed type aliases and deprecated exports
|
||||
|
||||
The following deprecated type aliases have been removed from `@modelcontextprotocol/core`:
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export { deserializeMessage, ReadBuffer, serializeMessage } from '../../shared/s
|
|||
// Transport types (NOT normalizeHeaders)
|
||||
export type { FetchLike, Transport, TransportSendOptions } from '../../shared/transport.js';
|
||||
export { createFetchWithInit } from '../../shared/transport.js';
|
||||
export { InMemoryTransport } from '../../util/inMemory.js';
|
||||
|
||||
// URI Template
|
||||
export type { Variables } from '../../shared/uriTemplate.js';
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ interface QueuedMessage {
|
|||
|
||||
/**
|
||||
* In-memory transport for creating clients and servers that talk to each other within the same process.
|
||||
*
|
||||
* Intended for testing and development. For production in-process connections, use
|
||||
* `StreamableHTTPClientTransport` against a local server URL.
|
||||
*/
|
||||
export class InMemoryTransport implements Transport {
|
||||
private _otherTransport?: InMemoryTransport;
|
||||
|
|
|
|||
Loading…
Reference in a new issue