cnks 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cnks/__init__.py +39 -0
- cnks/server.py +762 -0
- cnks-0.1.0.dist-info/METADATA +841 -0
- cnks-0.1.0.dist-info/RECORD +6 -0
- cnks-0.1.0.dist-info/WHEEL +4 -0
- cnks-0.1.0.dist-info/entry_points.txt +2 -0
cnks/__init__.py
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
from . import server
|
2
|
+
import asyncio
|
3
|
+
import sys
|
4
|
+
import json
|
5
|
+
from typing import Optional, Dict, Any
|
6
|
+
|
7
|
+
def add_note(name: str, content: str) -> None:
|
8
|
+
"""添加笔记到服务器"""
|
9
|
+
server.notes[name] = content
|
10
|
+
print(f"已添加笔记 '{name}': {content}")
|
11
|
+
|
12
|
+
def main():
|
13
|
+
"""主入口点"""
|
14
|
+
# 处理命令行参数
|
15
|
+
if len(sys.argv) > 1:
|
16
|
+
cmd = sys.argv[1]
|
17
|
+
if cmd == "add-note" and len(sys.argv) >= 4:
|
18
|
+
add_note(sys.argv[2], sys.argv[3])
|
19
|
+
return
|
20
|
+
elif cmd == "help":
|
21
|
+
print("使用方法:")
|
22
|
+
print(" cnks add-note <名称> <内容> - 添加笔记")
|
23
|
+
print(" cnks help - 显示此帮助信息")
|
24
|
+
print(" cnks - 启动MCP服务器")
|
25
|
+
return
|
26
|
+
|
27
|
+
# 默认启动服务器
|
28
|
+
# 尝试使用FastMCP接口,如果可用
|
29
|
+
fast_mcp = server.create_fastmcp_server()
|
30
|
+
if fast_mcp:
|
31
|
+
print("启动知网搜索FastMCP服务器...")
|
32
|
+
fast_mcp.run()
|
33
|
+
else:
|
34
|
+
# 回退到标准接口
|
35
|
+
print("启动知网搜索MCP服务器(低级接口)...")
|
36
|
+
asyncio.run(server.main())
|
37
|
+
|
38
|
+
# 导出重要项目
|
39
|
+
__all__ = ['main', 'server', 'add_note']
|