Skip to content

Commit 4f827e5

Browse files
domdomeggclaude
authored andcommitted
Add @deprecated annotations to legacy APIs (modelcontextprotocol#1018)
Co-authored-by: Claude <[email protected]>
1 parent 1761b5a commit 4f827e5

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/client/sse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export type SSEClientTransportOptions = {
5757
/**
5858
* Client transport for SSE: this will connect to a server using Server-Sent Events for receiving
5959
* messages and make separate POST requests for sending messages.
60+
* @deprecated SSEClientTransport is deprecated. Prefer to use StreamableHTTPClientTransport where possible instead. Note that because some servers are still using SSE, clients may need to support both transports during the migration period.
6061
*/
6162
export class SSEClientTransport implements Transport {
6263
private _eventSource?: EventSource;

src/server/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export type ServerOptions = ProtocolOptions & {
101101
* version: "1.0.0"
102102
* })
103103
* ```
104+
* @deprecated Use `McpServer` instead for the high-level API. Only use `Server` for advanced use cases.
104105
*/
105106
export class Server<
106107
RequestT extends Request = Request,

src/server/mcp.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,25 @@ export class McpServer {
446446

447447
/**
448448
* Registers a resource `name` at a fixed URI, which will use the given callback to respond to read requests.
449+
* @deprecated Use `registerResource` instead.
449450
*/
450451
resource(name: string, uri: string, readCallback: ReadResourceCallback): RegisteredResource;
451452

452453
/**
453454
* Registers a resource `name` at a fixed URI with metadata, which will use the given callback to respond to read requests.
455+
* @deprecated Use `registerResource` instead.
454456
*/
455457
resource(name: string, uri: string, metadata: ResourceMetadata, readCallback: ReadResourceCallback): RegisteredResource;
456458

457459
/**
458460
* Registers a resource `name` with a template pattern, which will use the given callback to respond to read requests.
461+
* @deprecated Use `registerResource` instead.
459462
*/
460463
resource(name: string, template: ResourceTemplate, readCallback: ReadResourceTemplateCallback): RegisteredResourceTemplate;
461464

462465
/**
463466
* Registers a resource `name` with a template pattern and metadata, which will use the given callback to respond to read requests.
467+
* @deprecated Use `registerResource` instead.
464468
*/
465469
resource(
466470
name: string,
@@ -718,11 +722,13 @@ export class McpServer {
718722

719723
/**
720724
* Registers a zero-argument tool `name`, which will run the given function when the client calls it.
725+
* @deprecated Use `registerTool` instead.
721726
*/
722727
tool(name: string, cb: ToolCallback): RegisteredTool;
723728

724729
/**
725730
* Registers a zero-argument tool `name` (with a description) which will run the given function when the client calls it.
731+
* @deprecated Use `registerTool` instead.
726732
*/
727733
tool(name: string, description: string, cb: ToolCallback): RegisteredTool;
728734

@@ -732,6 +738,7 @@ export class McpServer {
732738
*
733739
* Note: We use a union type for the second parameter because TypeScript cannot reliably disambiguate
734740
* between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types.
741+
* @deprecated Use `registerTool` instead.
735742
*/
736743
tool<Args extends ZodRawShapeCompat>(
737744
name: string,
@@ -746,6 +753,7 @@ export class McpServer {
746753
*
747754
* Note: We use a union type for the third parameter because TypeScript cannot reliably disambiguate
748755
* between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types.
756+
* @deprecated Use `registerTool` instead.
749757
*/
750758
tool<Args extends ZodRawShapeCompat>(
751759
name: string,
@@ -756,6 +764,7 @@ export class McpServer {
756764

757765
/**
758766
* Registers a tool with both parameter schema and annotations.
767+
* @deprecated Use `registerTool` instead.
759768
*/
760769
tool<Args extends ZodRawShapeCompat>(
761770
name: string,
@@ -766,6 +775,7 @@ export class McpServer {
766775

767776
/**
768777
* Registers a tool with description, parameter schema, and annotations.
778+
* @deprecated Use `registerTool` instead.
769779
*/
770780
tool<Args extends ZodRawShapeCompat>(
771781
name: string,
@@ -858,21 +868,25 @@ export class McpServer {
858868

859869
/**
860870
* Registers a zero-argument prompt `name`, which will run the given function when the client calls it.
871+
* @deprecated Use `registerPrompt` instead.
861872
*/
862873
prompt(name: string, cb: PromptCallback): RegisteredPrompt;
863874

864875
/**
865876
* Registers a zero-argument prompt `name` (with a description) which will run the given function when the client calls it.
877+
* @deprecated Use `registerPrompt` instead.
866878
*/
867879
prompt(name: string, description: string, cb: PromptCallback): RegisteredPrompt;
868880

869881
/**
870882
* Registers a prompt `name` accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
883+
* @deprecated Use `registerPrompt` instead.
871884
*/
872885
prompt<Args extends PromptArgsRawShape>(name: string, argsSchema: Args, cb: PromptCallback<Args>): RegisteredPrompt;
873886

874887
/**
875888
* Registers a prompt `name` (with a description) accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
889+
* @deprecated Use `registerPrompt` instead.
876890
*/
877891
prompt<Args extends PromptArgsRawShape>(
878892
name: string,

src/server/sse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface SSEServerTransportOptions {
3636
* Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.
3737
*
3838
* This transport is only available in Node.js environments.
39+
* @deprecated SSEServerTransport is deprecated. Use StreamableHTTPServerTransport instead.
3940
*/
4041
export class SSEServerTransport implements Transport {
4142
private _sseResponse?: ServerResponse;

0 commit comments

Comments
 (0)