Commit Graph

12 Commits

Author SHA1 Message Date
Cliff Hall
f8c05004d0 Open CORS for any origin to allow direct browser connection (#2725)
* * In src/everything/sse.ts
  - import cors
  - use cors with config allowing any origin + GET/POST
* In src/everything/streamableHttp.ts
  - import cors
    - use cors with config allowing any origin + GET/POST/DELETE, and exposed protocol headers for client to read
* In package.json and package-lock.json
  - add cors as a dependency

* * In package.json and package-lock.json
  - add @types/cors as dev dependency

* Add caution note for CORS origin wildcard usage

Added caution note for using '*' in CORS origin.

* * In streamableHttp.ts
  - remove remove unintentional console log

* * In streamableHttp.ts
  - add comment about why opening cors for all routes

* * In sse.ts
  - add comment about using * with caution in production for cors

* * In sse.ts
  - indent on cors config

---------

Co-authored-by: shaun smith <1936278+evalstate@users.noreply.github.com>
2025-09-19 01:28:41 +01:00
cliffhall
97c6408f04 * in .gitignore
- add .idea/ for Jetbrains IDEs
* in everything.ts
  - remove import of SetLevelRequestSchema
  - remove logLevel var
  - add sessionId var
  - in startNotificationIntervals function
    - add optional sid argument
    - set sessionId to sid
    - define messages to be sent, adding sessionId if present
  - remove setRequestHandler call for SetLevelRequestSchema
  - replace server.notification calls that sent "notifications/message" objects with calls to server.sendLoggingMessage, passing just the parameters and sessionId.
* In package.json & package-lock.json
  - bump TS SDK version to 1.17.5
* In sse.ts, pass transport.sessionId to startNotificationIntervals call
* In stdio.ts
  - destructure startNotificationIntervals from createServer call
  - implement custom logging request handler and server.sendLoggingMessage implementation, as a
  workaround for the fact that the SDK's automatic log level handling currently only tracks requested log level by session id. This will be fixed in a followup PR for the SDK
  - call the startNotificationIntervals function after connecting the transport to the server
* In streamableHttp.ts
  - destructure startNotificationIntervals from createServer call
  - call startNotificationIntervals passing the transport.sessionId after connecting the transport to the server
2025-09-02 17:18:11 -04:00
Cliff Hall
5f36973811 Merge pull request #1884 from cliffhall/everything-server-multiple-connection-support
Everything server multiple connection support
2025-05-29 10:41:51 -04:00
David Soria Parra
2dc1a34b75 update 2025-05-29 12:04:52 +01:00
cliffhall
145f893108 Allow multiple connections to the everything server.
For both sse and streamableHttp, a server instance needs to be created for each transport. Otherwise, when a new client connects and its new transport is connected to the single server, the previous transport is overwritten in the server instance and can no longer communicate.

* In sse.ts
  - remove global server, cleanup, and transport vars
  - add transports map
  - in sse GET handler,
    - check for sessionId, there shouldn't be one, so comment "Reconnecting?" and do nothing if present
    - if sessionId not present
      - create new server and transport instance
      - connect server to transport
      - add transport to transports map
      - in server.onclose, delete the transport from the transports map and call cleanup
  - in /message POST handler
    - get the sessionId from the request
    - get the transport from the map by sessionId
    - handle the message if the transport was found

* In streamableHttp.ts
  - remove the global server and cleanup vars
  - change transports var to Map
  - in /mcp POST handler
    - when creating a new session
      - create a server instance
      - in server.onclose, delete the transport from the transports map and call cleanup
  - remove the calls to cleanup and server.close in the SIGINT handler, because the transport is closed and its onclose handler closes the server.
2025-05-22 11:41:16 -04:00
cliffhall
3894d236c0 * In src/everything/sse.ts and streamableHttp.ts
- Replace console.log with console.error throughout
* In src/everything/sse.ts
  - remove the process.exit() in the server.onclose handler so reconnections are possible
2025-05-15 14:13:15 -04:00
cliffhall
e30f30868f Update server-everything to use the latest version of the SDK
* In sse.ts & streamableHttp.ts
  - change console.log to console.error
2025-05-06 10:27:49 -04:00
cliffhall
f93911607b Update server-everything to allow choosing the transport on the command line.
# Run the default (stdio) server
```npx @modelcontextprotocol/server-everything```

# Or specify stdio explicitly
```npx @modelcontextprotocol/server-everything stdio```

# Run the SSE server
```npx @modelcontextprotocol/server-everything sse```

# Run the streamable HTTP server
```npx @modelcontextprotocol/server-everything streamableHttp```

* In src/everything/index.ts
  - refactor/extracted contents to stdio.ts
  - replaced with code that
    - Gets the single argument from the commandline as scriptName
    - switches on scriptName
    - imports the appropriate server script or outputs usage options
  - scripts run on import

* In src/everything/stdio.ts
  - added console log "Starting default (STDIO) server..."

* In src/everything/sse.ts
  - added console log "Starting SSE server..."

* In src/everything/streamableHttp.ts
  - added console log "Starting Streamable HTTP server..."

* This fixes #1594
2025-05-05 13:09:38 -04:00
Shiv Deepak Muddada
e70bcd317b remove json middleware from everything streamable http server 2025-04-22 19:51:16 -07:00
Shiv Deepak Muddada
d1d79444f7 fix: passing body to handleRequest, and optionally adding a response id if it exists 2025-04-22 19:32:07 -07:00
Shiv Deepak Muddada
03e9a7be0d ref: cleanup 2025-04-22 19:32:03 -07:00
Shiv Deepak Muddada
07af15945d add streamableHttp server support for everything server 2025-04-22 19:27:00 -07:00