Skip to content

Commit 6164360

Browse files
Merge pull request #47 from modelcontextprotocol/justin/oss-prep
Add license information and more package metadata
2 parents f848aca + abafc46 commit 6164360

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2024 Anthropic, PBC.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,110 @@
11
# mcp-typescript
2-
TypeScript implementation of the Model Context Protocol
2+
3+
TypeScript implementation of the Model Context Protocol (MCP), providing both client and server capabilities for integrating with LLM surfaces.
4+
5+
## Overview
6+
7+
The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This TypeScript SDK implements the full MCP specification, making it easy to:
8+
9+
- Build MCP clients that can connect to any MCP server
10+
- Create MCP servers that expose resources, prompts and tools
11+
- Use standard transports like stdio and SSE
12+
- Handle all MCP protocol messages and lifecycle events
13+
14+
## Installation
15+
16+
```bash
17+
npm install @modelcontextprotocol/sdk
18+
```
19+
20+
## Quick Start
21+
22+
### Creating a Client
23+
24+
```typescript
25+
import { Client } from "@modelcontextprotocol/sdk/client";
26+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio";
27+
28+
const transport = new StdioClientTransport({
29+
command: "path/to/server",
30+
});
31+
32+
const client = new Client({
33+
name: "example-client",
34+
version: "1.0.0",
35+
});
36+
37+
await client.connect(transport);
38+
39+
// List available resources
40+
const resources = await client.request(
41+
{ method: "resources/list" },
42+
ListResourcesResultSchema
43+
);
44+
45+
// Read a specific resource
46+
const resourceContent = await client.request(
47+
{
48+
method: "resources/read",
49+
params: {
50+
uri: "file:///example.txt"
51+
}
52+
},
53+
ReadResourceResultSchema
54+
);
55+
```
56+
57+
### Creating a Server
58+
59+
```typescript
60+
import { Server } from "@modelcontextprotocol/sdk/server";
61+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio";
62+
63+
const server = new Server({
64+
name: "example-server",
65+
version: "1.0.0",
66+
});
67+
68+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
69+
return {
70+
resources: [
71+
{
72+
uri: "file:///example.txt",
73+
name: "Example Resource",
74+
},
75+
],
76+
};
77+
});
78+
79+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
80+
if (request.params.uri === "file:///example.txt") {
81+
return {
82+
contents: [
83+
{
84+
uri: "file:///example.txt",
85+
mimeType: "text/plain",
86+
text: "This is the content of the example resource.",
87+
},
88+
],
89+
};
90+
} else {
91+
throw new Error("Resource not found");
92+
}
93+
});
94+
95+
const transport = new StdioServerTransport();
96+
await server.connect(transport);
97+
```
98+
99+
## Documentation
100+
101+
- [MCP Specification](https://modelcontextprotocol.github.io)
102+
- [Example Servers](https://github.com/modelcontextprotocol/example-servers)
103+
104+
## Contributing
105+
106+
Issues and pull requests are welcome on GitHub at https://github.com/modelcontextprotocol/typescript-sdk.
107+
108+
## License
109+
110+
This project is licensed under the MIT License—see the [LICENSE](LICENSE) file for details.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@modelcontextprotocol/sdk",
33
"version": "0.3.3",
44
"description": "Model Context Protocol implementation for TypeScript",
5+
"license": "MIT",
6+
"author": "Anthropic, PBC (https://anthropic.com)",
7+
"homepage": "https://modelcontextprotocol.github.io",
8+
"bugs": "https://github.com/modelcontextprotocol/typescript-sdk/issues",
59
"type": "module",
610
"main": "./dist/index.js",
711
"types": "./dist/index.d.ts",

0 commit comments

Comments
 (0)