Merge pull request #30 from modelcontextprotocol/justin/npm
Switch to `npm`
This commit is contained in:
commit
8ff82d7f78
99 changed files with 5921 additions and 22356 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
|
@ -1,2 +1 @@
|
||||||
yarn.lock linguist-generated=true
|
package-lock.json linguist-generated=true
|
||||||
packages/**/* linguist-generated=true
|
|
||||||
|
|
|
||||||
37
.github/workflows/main.yml
vendored
Normal file
37
.github/workflows/main.yml
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: modelcontextprotocol/typescript-sdk
|
||||||
|
ssh-key: ${{ secrets.TYPESCRIPT_SDK_KEY }}
|
||||||
|
path: packages/@modelcontextprotocol/sdk
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
working-directory: packages/@modelcontextprotocol/sdk
|
||||||
|
|
||||||
|
- run: npm pack
|
||||||
|
working-directory: packages/@modelcontextprotocol/sdk
|
||||||
|
|
||||||
|
- run: npm install --save packages/@modelcontextprotocol/sdk/modelcontextprotocol-sdk-*.tgz
|
||||||
|
|
||||||
|
# Working around https://github.com/npm/cli/issues/4828
|
||||||
|
# - run: npm ci
|
||||||
|
- run: npm install --no-package-lock
|
||||||
|
- run: npm run build
|
||||||
|
|
@ -5,13 +5,13 @@ The MCP inspector is a developer tool for testing and debugging MCP servers.
|
||||||
Setup:
|
Setup:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
You can run it in dev mode via:
|
You can run it in dev mode via:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
This will start both the client and server.
|
This will start both the client and server.
|
||||||
|
|
@ -19,6 +19,6 @@ This will start both the client and server.
|
||||||
To run in production mode:
|
To run in production mode:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn build
|
npm run build
|
||||||
yarn start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@modelcontextprotocol/sdk": "*",
|
||||||
"@radix-ui/react-icons": "^1.3.0",
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
"@radix-ui/react-label": "^2.1.0",
|
"@radix-ui/react-label": "^2.1.0",
|
||||||
"@radix-ui/react-select": "^2.1.2",
|
"@radix-ui/react-select": "^2.1.2",
|
||||||
|
|
@ -18,7 +19,6 @@
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"lucide-react": "^0.447.0",
|
"lucide-react": "^0.447.0",
|
||||||
"mcp-typescript": "file:../packages/mcp-typescript",
|
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"tailwind-merge": "^2.5.3",
|
"tailwind-merge": "^2.5.3",
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,5 @@
|
||||||
import { Client } from "mcp-typescript/client/index.js";
|
|
||||||
import { SSEClientTransport } from "mcp-typescript/client/sse.js";
|
|
||||||
import {
|
|
||||||
ListResourcesResultSchema,
|
|
||||||
GetPromptResultSchema,
|
|
||||||
ListToolsResultSchema,
|
|
||||||
ReadResourceResultSchema,
|
|
||||||
CallToolResultSchema,
|
|
||||||
ListPromptsResultSchema,
|
|
||||||
Resource,
|
|
||||||
Tool,
|
|
||||||
ClientRequest,
|
|
||||||
ProgressNotificationSchema,
|
|
||||||
ServerNotification,
|
|
||||||
EmptyResultSchema,
|
|
||||||
} from "mcp-typescript/types.js";
|
|
||||||
import { useState, useRef, useEffect } from "react";
|
|
||||||
import {
|
|
||||||
Send,
|
|
||||||
Terminal,
|
|
||||||
Files,
|
|
||||||
Bell,
|
|
||||||
MessageSquare,
|
|
||||||
Hammer,
|
|
||||||
Play,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|
@ -34,17 +7,44 @@ import {
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||||
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
||||||
|
import {
|
||||||
|
CallToolResultSchema,
|
||||||
|
ClientRequest,
|
||||||
|
EmptyResultSchema,
|
||||||
|
GetPromptResultSchema,
|
||||||
|
ListPromptsResultSchema,
|
||||||
|
ListResourcesResultSchema,
|
||||||
|
ListToolsResultSchema,
|
||||||
|
ProgressNotificationSchema,
|
||||||
|
ReadResourceResultSchema,
|
||||||
|
Resource,
|
||||||
|
ServerNotification,
|
||||||
|
Tool,
|
||||||
|
} from "@modelcontextprotocol/sdk/types.js";
|
||||||
|
import {
|
||||||
|
Bell,
|
||||||
|
Files,
|
||||||
|
Hammer,
|
||||||
|
MessageSquare,
|
||||||
|
Play,
|
||||||
|
Send,
|
||||||
|
Terminal,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
|
import { AnyZodObject } from "zod";
|
||||||
|
import "./App.css";
|
||||||
import ConsoleTab from "./components/ConsoleTab";
|
import ConsoleTab from "./components/ConsoleTab";
|
||||||
import Sidebar from "./components/Sidebar";
|
import HistoryAndNotifications from "./components/History";
|
||||||
|
import PingTab from "./components/PingTab";
|
||||||
|
import PromptsTab, { Prompt } from "./components/PromptsTab";
|
||||||
import RequestsTab from "./components/RequestsTabs";
|
import RequestsTab from "./components/RequestsTabs";
|
||||||
import ResourcesTab from "./components/ResourcesTab";
|
import ResourcesTab from "./components/ResourcesTab";
|
||||||
import PromptsTab, { Prompt } from "./components/PromptsTab";
|
import Sidebar from "./components/Sidebar";
|
||||||
import ToolsTab from "./components/ToolsTab";
|
import ToolsTab from "./components/ToolsTab";
|
||||||
import { AnyZodObject } from "zod";
|
|
||||||
import HistoryAndNotifications from "./components/History";
|
|
||||||
import "./App.css";
|
|
||||||
import PingTab from "./components/PingTab";
|
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [connectionStatus, setConnectionStatus] = useState<
|
const [connectionStatus, setConnectionStatus] = useState<
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { useState } from "react";
|
import { ServerNotification } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { Copy } from "lucide-react";
|
import { Copy } from "lucide-react";
|
||||||
import { ServerNotification } from "mcp-typescript/types.js";
|
import { useState } from "react";
|
||||||
|
|
||||||
const HistoryAndNotifications = ({
|
const HistoryAndNotifications = ({
|
||||||
requestHistory,
|
requestHistory,
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { AlertCircle } from "lucide-react";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
import { TabsContent } from "@/components/ui/tabs";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { TabsContent } from "@/components/ui/tabs";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { ListPromptsResult } from "@modelcontextprotocol/sdk/types.js";
|
||||||
|
import { AlertCircle } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
import ListPane from "./ListPane";
|
import ListPane from "./ListPane";
|
||||||
import { ListPromptsResult } from "mcp-typescript/types.js";
|
|
||||||
|
|
||||||
export type Prompt = {
|
export type Prompt = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { FileText, ChevronRight, AlertCircle, RefreshCw } from "lucide-react";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
import { TabsContent } from "@/components/ui/tabs";
|
import { TabsContent } from "@/components/ui/tabs";
|
||||||
import { ListResourcesResult, Resource } from "mcp-typescript/types.js";
|
import { ListResourcesResult, Resource } from "@modelcontextprotocol/sdk/types.js";
|
||||||
|
import { AlertCircle, ChevronRight, FileText, RefreshCw } from "lucide-react";
|
||||||
import ListPane from "./ListPane";
|
import ListPane from "./ListPane";
|
||||||
|
|
||||||
const ResourcesTab = ({
|
const ResourcesTab = ({
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { TabsContent } from "@/components/ui/tabs";
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Send, AlertCircle } from "lucide-react";
|
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
||||||
import { ListToolsResult, Tool } from "mcp-typescript/types.js";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { TabsContent } from "@/components/ui/tabs";
|
||||||
|
import { ListToolsResult, Tool } from "@modelcontextprotocol/sdk/types.js";
|
||||||
|
import { AlertCircle, Send } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
import ListPane from "./ListPane";
|
import ListPane from "./ListPane";
|
||||||
|
|
||||||
const ToolsTab = ({
|
const ToolsTab = ({
|
||||||
|
|
|
||||||
5815
package-lock.json
generated
Normal file
5815
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
25
package.json
25
package.json
|
|
@ -3,20 +3,19 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"workspaces": ["client", "server"],
|
"workspaces": [
|
||||||
|
"client",
|
||||||
|
"server"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently \"cd client && yarn dev\" \"cd server && yarn dev\"",
|
"dev": "concurrently \"cd client && npm run dev\" \"cd server && npm run dev\"",
|
||||||
"build-server": "cd server && yarn build",
|
"build-server": "cd server && npm run build",
|
||||||
"build-client": "cd client && yarn build",
|
"build-client": "cd client && npm run build",
|
||||||
"build": "yarn build-server && yarn build-client",
|
"build": "npm run build-server && npm run build-client",
|
||||||
"start-server": "cd server && yarn start",
|
"start-server": "cd server && npm run start",
|
||||||
"start-client": "cd client && yarn preview",
|
"start-client": "cd client && npm run preview",
|
||||||
"start": "concurrently \"yarn start-server\" \"yarn start-client\"",
|
"start": "concurrently \"npm run start-server\" \"npm run start-client\"",
|
||||||
"prettier-fix": "prettier --write .",
|
"prettier-fix": "prettier --write ."
|
||||||
"update:mcp": "git subtree pull --prefix=packages/mcp-typescript https://github.com/modelcontextprotocol/typescript-sdk.git main --squash"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"mcp-typescript": "file:packages/mcp-typescript"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^9.0.1",
|
"concurrently": "^9.0.1",
|
||||||
|
|
|
||||||
1
packages/mcp-typescript/.gitattributes
vendored
1
packages/mcp-typescript/.gitattributes
vendored
|
|
@ -1 +0,0 @@
|
||||||
dist/**/* linguist-generated=true
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: yarn
|
|
||||||
|
|
||||||
- run: yarn install --immutable
|
|
||||||
- run: yarn build
|
|
||||||
|
|
||||||
- name: Verify that `yarn build` did not change outputs
|
|
||||||
run: git diff --exit-code
|
|
||||||
|
|
||||||
- run: yarn test
|
|
||||||
- run: yarn lint
|
|
||||||
131
packages/mcp-typescript/.gitignore
vendored
131
packages/mcp-typescript/.gitignore
vendored
|
|
@ -1,131 +0,0 @@
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# Snowpack dependency directory (https://snowpack.dev/)
|
|
||||||
web_modules/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Optional stylelint cache
|
|
||||||
.stylelintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variable files
|
|
||||||
.env
|
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
.env.local
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
.parcel-cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
out
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# vuepress v2.x temp and cache directory
|
|
||||||
.temp
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# Docusaurus cache and generated files
|
|
||||||
.docusaurus
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# Stores VSCode versions used for testing VSCode extensions
|
|
||||||
.vscode-test
|
|
||||||
|
|
||||||
# yarn v2
|
|
||||||
.yarn/cache
|
|
||||||
.yarn/unplugged
|
|
||||||
.yarn/build-state.yml
|
|
||||||
.yarn/install-state.gz
|
|
||||||
.pnp.*
|
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
# mcp-typescript
|
|
||||||
TypeScript implementation of the Model Context Protocol
|
|
||||||
2
packages/mcp-typescript/dist/cli.d.ts
vendored
2
packages/mcp-typescript/dist/cli.d.ts
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
export {};
|
|
||||||
//# sourceMappingURL=cli.d.ts.map
|
|
||||||
1
packages/mcp-typescript/dist/cli.d.ts.map
vendored
1
packages/mcp-typescript/dist/cli.d.ts.map
vendored
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
|
||||||
114
packages/mcp-typescript/dist/cli.js
vendored
114
packages/mcp-typescript/dist/cli.js
vendored
|
|
@ -1,114 +0,0 @@
|
||||||
import EventSource from "eventsource";
|
|
||||||
import WebSocket from "ws";
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
global.EventSource = EventSource;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
global.WebSocket = WebSocket;
|
|
||||||
import express from "express";
|
|
||||||
import { Client } from "./client/index.js";
|
|
||||||
import { SSEClientTransport } from "./client/sse.js";
|
|
||||||
import { Server } from "./server/index.js";
|
|
||||||
import { SSEServerTransport } from "./server/sse.js";
|
|
||||||
import { WebSocketClientTransport } from "./client/websocket.js";
|
|
||||||
import { StdioClientTransport } from "./client/stdio.js";
|
|
||||||
import { StdioServerTransport } from "./server/stdio.js";
|
|
||||||
async function runClient(url_or_command, args) {
|
|
||||||
const client = new Client({
|
|
||||||
name: "mcp-typescript test client",
|
|
||||||
version: "0.1.0",
|
|
||||||
});
|
|
||||||
let clientTransport;
|
|
||||||
let url = undefined;
|
|
||||||
try {
|
|
||||||
url = new URL(url_or_command);
|
|
||||||
}
|
|
||||||
catch (_a) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
if ((url === null || url === void 0 ? void 0 : url.protocol) === "http:" || (url === null || url === void 0 ? void 0 : url.protocol) === "https:") {
|
|
||||||
clientTransport = new SSEClientTransport(new URL(url_or_command));
|
|
||||||
}
|
|
||||||
else if ((url === null || url === void 0 ? void 0 : url.protocol) === "ws:" || (url === null || url === void 0 ? void 0 : url.protocol) === "wss:") {
|
|
||||||
clientTransport = new WebSocketClientTransport(new URL(url_or_command));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clientTransport = new StdioClientTransport({
|
|
||||||
command: url_or_command,
|
|
||||||
args,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.log("Connected to server.");
|
|
||||||
await client.connect(clientTransport);
|
|
||||||
console.log("Initialized.");
|
|
||||||
await client.close();
|
|
||||||
console.log("Closed.");
|
|
||||||
}
|
|
||||||
async function runServer(port) {
|
|
||||||
if (port !== null) {
|
|
||||||
const app = express();
|
|
||||||
let servers = [];
|
|
||||||
app.get("/sse", async (req, res) => {
|
|
||||||
console.log("Got new SSE connection");
|
|
||||||
const transport = new SSEServerTransport("/message", res);
|
|
||||||
const server = new Server({
|
|
||||||
name: "mcp-typescript test server",
|
|
||||||
version: "0.1.0",
|
|
||||||
});
|
|
||||||
servers.push(server);
|
|
||||||
server.onclose = () => {
|
|
||||||
console.log("SSE connection closed");
|
|
||||||
servers = servers.filter((s) => s !== server);
|
|
||||||
};
|
|
||||||
await server.connect(transport);
|
|
||||||
});
|
|
||||||
app.post("/message", async (req, res) => {
|
|
||||||
console.log("Received message");
|
|
||||||
const sessionId = req.query.sessionId;
|
|
||||||
const transport = servers
|
|
||||||
.map((s) => s.transport)
|
|
||||||
.find((t) => t.sessionId === sessionId);
|
|
||||||
if (!transport) {
|
|
||||||
res.status(404).send("Session not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await transport.handlePostMessage(req, res);
|
|
||||||
});
|
|
||||||
app.listen(port, () => {
|
|
||||||
console.log(`Server running on http://localhost:${port}/sse`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const server = new Server({
|
|
||||||
name: "mcp-typescript test server",
|
|
||||||
version: "0.1.0",
|
|
||||||
});
|
|
||||||
const transport = new StdioServerTransport();
|
|
||||||
await server.connect(transport);
|
|
||||||
console.log("Server running on stdio");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const args = process.argv.slice(2);
|
|
||||||
const command = args[0];
|
|
||||||
switch (command) {
|
|
||||||
case "client":
|
|
||||||
if (args.length < 2) {
|
|
||||||
console.error("Usage: client <server_url_or_command> [args...]");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
runClient(args[1], args.slice(2)).catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "server": {
|
|
||||||
const port = args[1] ? parseInt(args[1]) : null;
|
|
||||||
runServer(port).catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
console.error("Unrecognized command:", command);
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=cli.js.map
|
|
||||||
1
packages/mcp-typescript/dist/cli.js.map
vendored
1
packages/mcp-typescript/dist/cli.js.map
vendored
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,SAAS,MAAM,IAAI,CAAC;AAE3B,8DAA8D;AAC7D,MAAc,CAAC,WAAW,GAAG,WAAW,CAAC;AAC1C,8DAA8D;AAC7D,MAAc,CAAC,SAAS,GAAG,SAAS,CAAC;AAEtC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;A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C;QAClB,CAAC,CAAC,CAAC;QAEH,MAAM;IAER,KAAK,QAAQ,CAAC,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAChD,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,MAAM;IACR,CAAC;IAED;QACE,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC"}
|
|
||||||
27
packages/mcp-typescript/dist/client/index.d.ts
vendored
27
packages/mcp-typescript/dist/client/index.d.ts
vendored
|
|
@ -1,27 +0,0 @@
|
||||||
import { Protocol } from "../shared/protocol.js";
|
|
||||||
import { Transport } from "../shared/transport.js";
|
|
||||||
import { ClientNotification, ClientRequest, ClientResult, Implementation, ServerCapabilities } from "../types.js";
|
|
||||||
/**
|
|
||||||
* An MCP client on top of a pluggable transport.
|
|
||||||
*
|
|
||||||
* The client will automatically begin the initialization flow with the server when connect() is called.
|
|
||||||
*/
|
|
||||||
export declare class Client extends Protocol<ClientRequest, ClientNotification, ClientResult> {
|
|
||||||
private _clientInfo;
|
|
||||||
private _serverCapabilities?;
|
|
||||||
private _serverVersion?;
|
|
||||||
/**
|
|
||||||
* Initializes this client with the given name and version information.
|
|
||||||
*/
|
|
||||||
constructor(_clientInfo: Implementation);
|
|
||||||
connect(transport: Transport): Promise<void>;
|
|
||||||
/**
|
|
||||||
* After initialization has completed, this will be populated with the server's reported capabilities.
|
|
||||||
*/
|
|
||||||
getServerCapabilities(): ServerCapabilities | undefined;
|
|
||||||
/**
|
|
||||||
* After initialization has completed, this will be populated with information about the server's name and version.
|
|
||||||
*/
|
|
||||||
getServerVersion(): Implementation | undefined;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=index.d.ts.map
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue