Skip to content

Commit 908c17e

Browse files
author
sherlin
committed
update sse README.md
1 parent 41b631e commit 908c17e

File tree

4 files changed

+58
-20
lines changed

4 files changed

+58
-20
lines changed

README.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
🌐 <a href="https://github.com/XGenerationLab/XiYan-SQL" >XiYan-SQL</a> |
1313
📖 <a href="https://arxiv.org/abs/2411.08599"> Arxiv</a> |
1414
📄 <a href="https://paperswithcode.com/paper/xiyan-sql-a-multi-generator-ensemble" >PapersWithCode</a>
15-
💻 <a href="https://huggingface.co/collections/XGenerationLab/xiyansql-models-67c9844307b49f87436808fc">HuggingFace</a> |
15+
🤗 <a href="https://huggingface.co/collections/XGenerationLab/xiyansql-models-67c9844307b49f87436808fc">HuggingFace</a> |
1616
🤖 <a href="https://modelscope.cn/collections/XiYanSQL-Models-4483337b614241" >ModelScope</a> |
1717
🌕 <a href="https://bailian.console.aliyun.com/xiyan">析言GBI</a>
1818
<br />
@@ -282,7 +282,10 @@ database:
282282
283283
Note that ``dialect`` should be ``postgresql`` for postgresql.
284284
## Launch
285-
### Claude Desktop
285+
286+
### STDIO Transport
287+
Normally, stdio transport is used with the specific mcp application as follows.
288+
#### Claude Desktop
286289
Add this in your Claude Desktop config file, ref <a href="https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/claude_desktop.jpg">Claude Desktop config example</a>
287290
```json
288291
{
@@ -301,26 +304,47 @@ Add this in your Claude Desktop config file, ref <a href="https://github.com/XGe
301304
}
302305
```
303306
**Please note that the Python command here requires the complete path to the Python executable (`/xxx/python`); otherwise, the Python interpreter cannot be found. You can determine this path by using the command `which python`. The same applies to other applications as well.**
304-
### Cline
307+
#### Cline
305308
Prepare the config like [Claude Desktop](#claude-desktop)
306309

307-
### Goose
310+
#### Goose
308311
Add following command in the config, ref <a href="https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/goose.jpg">Goose config example</a>
309312

310313
```yaml
311314
env YML=path/to/yml /xxx/python -m xiyan_mcp_server
312315
```
313-
### Cursor
316+
#### Cursor
314317
Use the same command like [Goose](#goose).
315318

316319

317-
### Witsy
320+
#### Witsy
318321
Add following in command:
319-
```yaml
322+
```shell
320323
/xxx/python -m xiyan_mcp_server
321324
```
322325
Add an env: key is YML and value is the path to your yml file.
323326
Ref <a href="https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/witsy.jpg">Witsy config example</a>
327+
328+
### SSE Transport
329+
SSE transport server has to be started with the following command first. The server runs defaultly on port 8000. You can change it by setting the environment variable FASTMCP_PORT.
330+
```shell
331+
env YML=path/to/yml FASTMCP_PORT=8000 python -m xiyan_mcp_server sse
332+
```
333+
You may also change the host or other parameters by setting the corresponding environment variables, but these are not fully tested.
334+
Then you should see the information on http://localhost:8000/sse in your browser.
335+
336+
Then you can use the server in applications mentioned above. For example, the config of Cursor is like this:
337+
```json
338+
{
339+
"mcpServers": {
340+
"xiyan-mcp-server": {
341+
"url": "http://127.0.0.1:8000/sse"
342+
}
343+
}
344+
}
345+
```
346+
347+
324348
## It Does Not Work!
325349
Contact us:
326350
<a href="https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/dinggroup_out.png">Ding Group钉钉群</a>|

src/xiyan_mcp_server/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
import argparse
12

2-
# Expose important items at package level
3-
__all__ = ['server']
3+
from .server import mcp
4+
5+
6+
7+
def main():
8+
parser = argparse.ArgumentParser(description="Run MCP server.")
9+
parser.add_argument('transport', nargs='?', default='stdio', choices=['stdio', 'sse'],
10+
help='Transport type (stdio or sse)')
11+
args = parser.parse_args()
12+
mcp.run(transport=args.transport)
13+
14+
if __name__ == "__main__":
15+
main()

src/xiyan_mcp_server/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import argparse
22
import sys
33

4-
from .server import run_mcp
4+
from .server import mcp
55

66

77
def main():
88
parser = argparse.ArgumentParser(description="Run MCP server.")
9-
parser.add_argument("-transport", type=str, default="stdio",
10-
help="Transport method: 'stdio' or 'sse'")
9+
parser.add_argument('transport', nargs='?', default='stdio', choices=['stdio', 'sse'],
10+
help='Transport type (stdio or sse)')
1111
args = parser.parse_args(sys.argv[1:]) # 忽略第一个参数(模块名)
12-
run_mcp(transport=args.transport)
12+
mcp.run(transport=args.transport)
1313

1414
if __name__ == "__main__":
1515
main()

src/xiyan_mcp_server/server.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,20 @@ def get_data(query: str)-> list[TextContent]:
178178
"""Fetch the data from database through a natural language query
179179
180180
Args:
181-
query: The query in natual language
181+
query: The query in natural language
182182
"""
183183

184184
res=call_xiyan(query)
185185
return [TextContent(type="text", text=res)]
186186

187187

188-
def run_mcp(transport: Literal["stdio", "sse"] = "stdio"):
189-
"""Start the MCP server with the specified transport method.
190188

191-
Args:
192-
transport (str): The transport method to use, either "stdio" or "sse".
193-
"""
194-
mcp.run(transport=transport)
189+
def main():
190+
parser = argparse.ArgumentParser(description="Run MCP server.")
191+
parser.add_argument('transport', nargs='?', default='stdio', choices=['stdio', 'sse'],
192+
help='Transport type (stdio or sse)')
193+
args = parser.parse_args()
194+
mcp.run(transport=args.transport)
195195

196+
if __name__ == "__main__":
197+
main()

0 commit comments

Comments
 (0)