Skip to content

Commit 2be8fbc

Browse files
authored
Merge pull request #56 from doitintl/feature/talc/sse-server
feat(mcp): add sse transport server
2 parents ce56789 + 81466e7 commit 2be8fbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+18009
-119
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![NPM Version](https://img.shields.io/npm/v/%40doitintl%2Fdoit-mcp-server?registry_uri=https%3A%2F%2Fregistry.npmjs.com%2F%40doitintl%2Fdoit-mcp-server)
44

5-
65
DoiT MCP Server provides access to the DoiT API. This server enables LLMs like Claude to access DoiT platform data for troubleshooting and analysis.
76

87
![top-services](https://github.com/user-attachments/assets/749dd237-3021-439d-b447-64605393389d)
@@ -11,14 +10,32 @@ DoiT MCP Server provides access to the DoiT API. This server enables LLMs like C
1110

1211
- Node.js v18 or higher
1312
- DoiT API key with appropriate permissions
14-
- Customer context identifier (for customer-specific data)
1513

1614
## Installation
1715

1816
To get your DoiT API key, visit the [API key section in your DoiT profile](https://help.doit.com/docs/general/profile#api-key).
1917

2018
There are several ways to install and configure the MCP server:
2119

20+
### DoiT MCP URL
21+
22+
The DoiT MCP server is available at: https://mcp.doit.com/sse
23+
24+
### Claude Desktop App
25+
26+
```json
27+
{
28+
"mcpServers": {
29+
"doit_mcp_server": {
30+
"command": "npx",
31+
"args": ["mcp-remote", "https://mcp.doit.com/sse"]
32+
}
33+
}
34+
}
35+
```
36+
37+
## STDIO - local server
38+
2239
### Claude Desktop App
2340

2441
To manually configure the MCP server for Claude Desktop App, add the following to your `claude_desktop_config.json` file or through "Settings" as described [here](https://modelcontextprotocol.io/quickstart/user#2-add-the-filesystem-mcp-server):

doit-mcp-server/.gitignore

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
node_modules
2+
3+
.nx
4+
.idea
5+
.vscode
6+
.zed
7+
# Logs
8+
9+
logs
10+
_.log
11+
npm-debug.log_
12+
yarn-debug.log*
13+
yarn-error.log*
14+
lerna-debug.log*
15+
.pnpm-debug.log*
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
\*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
\*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
\*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
\*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.cache
112+
.parcel-cache
113+
114+
# Next.js build output
115+
116+
.next
117+
out
118+
119+
# Nuxt.js build / generate output
120+
121+
.nuxt
122+
dist
123+
124+
# Gatsby files
125+
126+
.cache/
127+
128+
# Comment in the public line in if your project uses Gatsby and not Next.js
129+
130+
# https://nextjs.org/blog/next-9-1#public-directory-support
131+
132+
# public
133+
134+
# vuepress build output
135+
136+
.vuepress/dist
137+
138+
# vuepress v2.x temp and cache directory
139+
140+
.temp
141+
.cache
142+
143+
# Docusaurus cache and generated files
144+
145+
.docusaurus
146+
147+
# Serverless directories
148+
149+
.serverless/
150+
151+
# FuseBox cache
152+
153+
.fusebox/
154+
155+
# DynamoDB Local files
156+
157+
.dynamodb/
158+
159+
# TernJS port file
160+
161+
.tern-port
162+
163+
# Stores VSCode versions used for testing VSCode extensions
164+
165+
.vscode-test
166+
167+
# yarn v2
168+
169+
.yarn/cache
170+
.yarn/unplugged
171+
.yarn/build-state.yml
172+
.yarn/install-state.gz
173+
.pnp.\*
174+
175+
# wrangler project
176+
177+
.dev.vars
178+
.wrangler/

doit-mcp-server/README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Remote MCP Server on Cloudflare
2+
3+
Let's get a remote MCP server up-and-running on Cloudflare Workers complete with OAuth login!
4+
5+
## Develop locally
6+
7+
```bash
8+
# clone the repository
9+
git clone https://github.com/cloudflare/ai.git
10+
# Or if using ssh:
11+
# git clone git@github.com:cloudflare/ai.git
12+
13+
# install dependencies
14+
cd ai
15+
# Note: using pnpm instead of just "npm"
16+
pnpm install
17+
18+
# run locally
19+
npx nx dev remote-mcp-server
20+
```
21+
22+
You should be able to open [`http://localhost:8787/`](http://localhost:8787/) in your browser
23+
24+
## Connect the MCP inspector to your server
25+
26+
To explore your new MCP api, you can use the [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector).
27+
28+
- Start it with `npx @modelcontextprotocol/inspector`
29+
- [Within the inspector](http://localhost:5173), switch the Transport Type to `SSE` and enter `http://localhost:8787/sse` as the URL of the MCP server to connect to, and click "Connect"
30+
- You will navigate to a (mock) user/password login screen. Input any email and pass to login.
31+
- You should be redirected back to the MCP Inspector and you can now list and call any defined tools!
32+
33+
<div align="center">
34+
<img src="img/mcp-inspector-sse-config.png" alt="MCP Inspector with the above config" width="600"/>
35+
</div>
36+
37+
<div align="center">
38+
<img src="img/mcp-inspector-successful-tool-call.png" alt="MCP Inspector with after a tool call" width="600"/>
39+
</div>
40+
41+
## Connect Claude Desktop to your local MCP server
42+
43+
The MCP inspector is great, but we really want to connect this to Claude! Follow [Anthropic's Quickstart](https://modelcontextprotocol.io/quickstart/user) and within Claude Desktop go to Settings > Developer > Edit Config to find your configuration file.
44+
45+
Open the file in your text editor and replace it with this configuration:
46+
47+
```json
48+
{
49+
"mcpServers": {
50+
"math": {
51+
"command": "npx",
52+
"args": [
53+
"mcp-remote",
54+
"http://localhost:8787/sse"
55+
]
56+
}
57+
}
58+
}
59+
```
60+
61+
This will run a local proxy and let Claude talk to your MCP server over HTTP
62+
63+
When you open Claude a browser window should open and allow you to login. You should see the tools available in the bottom right. Given the right prompt Claude should ask to call the tool.
64+
65+
<div align="center">
66+
<img src="img/available-tools.png" alt="Clicking on the hammer icon shows a list of available tools" width="600"/>
67+
</div>
68+
69+
<div align="center">
70+
<img src="img/claude-does-math-the-fancy-way.png" alt="Claude answers the prompt 'I seem to have lost my calculator and have run out of fingers. Could you use the math tool to add 23 and 19?' by invoking the MCP add tool" width="600"/>
71+
</div>
72+
73+
## Deploy to Cloudflare
74+
75+
1. `npx wrangler kv namespace create OAUTH_KV`
76+
2. Follow the guidance to add the kv namespace ID to `wrangler.jsonc`
77+
3. `npm run deploy`
78+
79+
## Call your newly deployed remote MCP server from a remote MCP client
80+
81+
Just like you did above in "Develop locally", run the MCP inspector:
82+
83+
`npx @modelcontextprotocol/inspector@latest`
84+
85+
Then enter the `workers.dev` URL (ex: `worker-name.account-name.workers.dev/sse`) of your Worker in the inspector as the URL of the MCP server to connect to, and click "Connect".
86+
87+
You've now connected to your MCP server from a remote MCP client.
88+
89+
## Connect Claude Desktop to your remote MCP server
90+
91+
Update the Claude configuration file to point to your `workers.dev` URL (ex: `worker-name.account-name.workers.dev/sse`) and restart Claude
92+
93+
```json
94+
{
95+
"mcpServers": {
96+
"math": {
97+
"command": "npx",
98+
"args": [
99+
"mcp-remote",
100+
"https://worker-name.account-name.workers.dev/sse"
101+
]
102+
}
103+
}
104+
}
105+
```
106+
107+
## Debugging
108+
109+
Should anything go wrong it can be helpful to restart Claude, or to try connecting directly to your
110+
MCP server on the command line with the following command.
111+
112+
```bash
113+
npx mcp-remote http://localhost:8787/sse
114+
```
115+
116+
In some rare cases it may help to clear the files added to `~/.mcp-auth`
117+
118+
```bash
119+
rm -rf ~/.mcp-auth
120+
```

doit-mcp-server/biome.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
3+
"assist": {
4+
"actions": {
5+
"source": {
6+
"useSortedKeys": "on"
7+
}
8+
},
9+
"enabled": true
10+
},
11+
"files": {
12+
"includes": ["!worker-configuration.d.ts"]
13+
},
14+
"formatter": {
15+
"enabled": true,
16+
"indentWidth": 4,
17+
"lineWidth": 100
18+
},
19+
"linter": {
20+
"enabled": true,
21+
"rules": {
22+
"recommended": true,
23+
"style": {
24+
"noInferrableTypes": "error",
25+
"noNonNullAssertion": "off",
26+
"noParameterAssign": "error",
27+
"noUnusedTemplateLiteral": "error",
28+
"noUselessElse": "error",
29+
"useAsConstAssertion": "error",
30+
"useDefaultParameterLast": "error",
31+
"useEnumInitializers": "error",
32+
"useNumberNamespace": "error",
33+
"useSelfClosingElements": "error",
34+
"useSingleVarDeclarator": "error"
35+
},
36+
"suspicious": {
37+
"noConfusingVoidType": "off",
38+
"noDebugger": "off",
39+
"noExplicitAny": "off"
40+
}
41+
}
42+
},
43+
"root": false,
44+
"vcs": {
45+
"clientKind": "git",
46+
"enabled": true,
47+
"useIgnoreFile": true
48+
}
49+
}
91.5 KB
Loading
Loading

doit-mcp-server/img/doit-logo.svg

Lines changed: 6 additions & 0 deletions
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)