Skip to content

Commit 2166047

Browse files
domdomeggclaude
andauthored
Add @deprecated annotations to legacy APIs (#1018)
Co-authored-by: Claude <[email protected]>
1 parent 664e66e commit 2166047

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
@@ -425,21 +425,25 @@ export class McpServer {
425425

426426
/**
427427
* Registers a resource `name` at a fixed URI, which will use the given callback to respond to read requests.
428+
* @deprecated Use `registerResource` instead.
428429
*/
429430
resource(name: string, uri: string, readCallback: ReadResourceCallback): RegisteredResource;
430431

431432
/**
432433
* Registers a resource `name` at a fixed URI with metadata, which will use the given callback to respond to read requests.
434+
* @deprecated Use `registerResource` instead.
433435
*/
434436
resource(name: string, uri: string, metadata: ResourceMetadata, readCallback: ReadResourceCallback): RegisteredResource;
435437

436438
/**
437439
* Registers a resource `name` with a template pattern, which will use the given callback to respond to read requests.
440+
* @deprecated Use `registerResource` instead.
438441
*/
439442
resource(name: string, template: ResourceTemplate, readCallback: ReadResourceTemplateCallback): RegisteredResourceTemplate;
440443

441444
/**
442445
* Registers a resource `name` with a template pattern and metadata, which will use the given callback to respond to read requests.
446+
* @deprecated Use `registerResource` instead.
443447
*/
444448
resource(
445449
name: string,
@@ -689,11 +693,13 @@ export class McpServer {
689693

690694
/**
691695
* Registers a zero-argument tool `name`, which will run the given function when the client calls it.
696+
* @deprecated Use `registerTool` instead.
692697
*/
693698
tool(name: string, cb: ToolCallback): RegisteredTool;
694699

695700
/**
696701
* Registers a zero-argument tool `name` (with a description) which will run the given function when the client calls it.
702+
* @deprecated Use `registerTool` instead.
697703
*/
698704
tool(name: string, description: string, cb: ToolCallback): RegisteredTool;
699705

@@ -703,6 +709,7 @@ export class McpServer {
703709
*
704710
* Note: We use a union type for the second parameter because TypeScript cannot reliably disambiguate
705711
* between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types.
712+
* @deprecated Use `registerTool` instead.
706713
*/
707714
tool<Args extends ZodRawShape>(name: string, paramsSchemaOrAnnotations: Args | ToolAnnotations, cb: ToolCallback<Args>): RegisteredTool;
708715

@@ -713,6 +720,7 @@ export class McpServer {
713720
*
714721
* Note: We use a union type for the third parameter because TypeScript cannot reliably disambiguate
715722
* between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types.
723+
* @deprecated Use `registerTool` instead.
716724
*/
717725
tool<Args extends ZodRawShape>(
718726
name: string,
@@ -723,11 +731,13 @@ export class McpServer {
723731

724732
/**
725733
* Registers a tool with both parameter schema and annotations.
734+
* @deprecated Use `registerTool` instead.
726735
*/
727736
tool<Args extends ZodRawShape>(name: string, paramsSchema: Args, annotations: ToolAnnotations, cb: ToolCallback<Args>): RegisteredTool;
728737

729738
/**
730739
* Registers a tool with description, parameter schema, and annotations.
740+
* @deprecated Use `registerTool` instead.
731741
*/
732742
tool<Args extends ZodRawShape>(
733743
name: string,
@@ -820,21 +830,25 @@ export class McpServer {
820830

821831
/**
822832
* Registers a zero-argument prompt `name`, which will run the given function when the client calls it.
833+
* @deprecated Use `registerPrompt` instead.
823834
*/
824835
prompt(name: string, cb: PromptCallback): RegisteredPrompt;
825836

826837
/**
827838
* Registers a zero-argument prompt `name` (with a description) which will run the given function when the client calls it.
839+
* @deprecated Use `registerPrompt` instead.
828840
*/
829841
prompt(name: string, description: string, cb: PromptCallback): RegisteredPrompt;
830842

831843
/**
832844
* 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.
845+
* @deprecated Use `registerPrompt` instead.
833846
*/
834847
prompt<Args extends PromptArgsRawShape>(name: string, argsSchema: Args, cb: PromptCallback<Args>): RegisteredPrompt;
835848

836849
/**
837850
* 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.
851+
* @deprecated Use `registerPrompt` instead.
838852
*/
839853
prompt<Args extends PromptArgsRawShape>(
840854
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)