@uni-helper/mcp 0.0.2-beta.2 → 0.0.5
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.
- package/README.md +20 -12
- package/dist/docs/index.mjs +33 -0
- package/dist/index.mjs +9 -419
- package/dist/package.mjs +5 -0
- package/dist/server/index.mjs +26 -0
- package/package.json +14 -14
- package/scripts/download-model.mjs +4 -1
- package/scripts/link-global.mjs +56 -0
- package/vectorStore/uniapp_docs.lance/_transactions/0-216101b3-fd5d-40fc-89fd-7772bc3aa6b5.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/1-6437b0ef-cf2a-42dc-bb6c-501af0aa06fd.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/10-583e6655-8491-4092-bb4d-f323f7971c7b.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/11-5ff44c53-ec93-46dc-9d81-130bec6223c8.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/12-ac577081-8fe9-46c0-963b-69111ca65fc4.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/13-6c65bd6e-b8da-4f38-823b-f282d9770351.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/14-471061ce-2fcc-4c90-8a2f-c76cab9bb6a8.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/15-ce53c8df-f78d-448e-bc97-028312dd33ea.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/16-6a288bd5-73e4-48aa-b454-95132c8e46e3.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/17-83ba6cbd-8ce6-4011-b0e2-83bf43603fa5.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/18-609e7699-6e28-444a-aad5-6089b4d3cc88.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/19-5460b193-2f20-4150-a6d9-c2c81281977f.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/2-eeb82556-2a38-4d41-8f86-f3ace50a2dce.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/20-4554f36b-fcde-40f6-8f33-4f6a6248752f.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/21-763c7e7e-4265-4c56-bb93-2a7ade83ec7b.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/22-369bf229-12c1-4b7a-be1a-52d14ffc3d9c.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/23-56237775-2ab9-4d76-93b3-35f614cd7ef9.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/24-d6ab86bb-b149-4ac6-a73f-1cefa70c49f1.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/25-355a3a54-1321-4498-93e1-bc53bd432fe8.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/26-41bf6e47-0e38-4f35-8c95-d31584fdaacd.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/27-37b3c9b2-92aa-419a-8b96-4242f37ed460.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/28-ebe100f6-9250-407b-91dc-cd6a5a0e17a7.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/29-33075d55-06dd-4bd7-b6fa-37e9ad5c774b.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/3-b4f03119-2ef8-422f-ac04-0e95166c7949.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/30-622be085-cb51-4f24-b174-3d6aadf52d05.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/31-f2c367e3-624e-40db-8852-7e0b5ae612df.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/32-f5c117aa-6366-42f2-a5fe-f9157ecd5e53.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/33-fce4908c-c8ef-405b-8898-ee01dc5f2054.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/34-7fbfcff2-7eee-4252-a434-2b2b20553c4c.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/35-9d1f2870-dac6-4985-be03-6ad9a0ff0697.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/36-3bbe37e5-3cb8-4187-815c-dfd0d58b6599.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/37-b84bc7db-ca2b-4286-8969-39bb24a88814.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/38-dbfb158a-64be-4dc6-86b7-6a91c4ad9bee.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/39-ad902204-a08c-4911-816e-c766a1082656.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/4-ff5df285-aabb-4312-a603-b43de3c95a97.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/40-0fe9bf95-e500-4c0e-80cd-2e43ae69298c.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/41-b11071be-5b61-4177-8477-cad82e631e1a.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/42-0837a463-6fd1-42dc-98ef-1675c0a7adb7.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/43-61cf42f7-2a7a-4c4b-a60f-acf2bb371938.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/44-43bcd722-cc59-421a-8a74-a83291b95e4f.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/45-b9d4e7ae-9d73-47e4-9976-be81cf8739f0.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/46-061b8dd2-8316-47c1-815c-93dae46f8845.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/47-376e2402-5e5c-41da-97af-9ab8357fdb4d.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/48-55561b0c-47f8-4a16-8479-ac6f6fcf4d54.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/49-482d8449-746b-4d32-a29a-c88f09efed0b.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/5-bfe95c43-8276-4c63-ae9c-3ff1732ed9fa.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/50-633ff746-0e80-400c-8930-d70575a555a3.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/51-cad3a0a8-f41d-49cd-8ee3-4c778cb4b4d4.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/52-4e8880e0-63c3-4a7a-942c-a5ccf2d188c6.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/53-fcdbaf33-2eb1-4cbb-8fd2-bd2b5812a64f.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/54-cbfb60b6-0bf9-44b3-a337-22fec523cf4d.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/55-ba046998-b5ea-494c-a11f-fb26fb5426b4.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/6-43ba5dd5-ca67-4579-b888-a54c449753d8.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/7-3b2bbb71-a225-4ec9-9d65-3cf716329b7f.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/8-7c55a19a-afe7-4823-9df5-5211dd640b7c.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_transactions/9-f8322e81-7a7a-4483-9db9-0e06dfdd50d8.txn +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/1.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/10.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/11.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/12.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/13.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/14.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/15.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/16.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/17.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/18.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/19.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/2.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/20.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/21.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/22.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/23.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/24.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/25.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/26.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/27.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/28.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/29.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/3.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/30.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/31.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/32.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/33.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/34.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/35.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/36.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/37.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/38.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/39.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/4.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/40.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/41.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/42.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/43.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/44.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/45.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/46.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/47.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/48.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/49.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/5.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/50.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/51.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/52.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/53.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/54.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/55.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/56.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/6.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/7.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/8.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/_versions/9.manifest +0 -0
- package/vectorStore/uniapp_docs.lance/data/0000000011000011010111004798f048fd9d03e9b671e07c01.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/000001101011110011000010488cb94327934cc182bcaac59c.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/00001011111001101011100032d0564e87b6d5921257226ffc.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/00001110001011101011101187387246ba85e075f5b783035d.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/000011100011001111001010248b8a4db5a2760797f5c981d8.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/00010011001101100010001032a0d144eebecf02cb545b389a.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0001011101001011010100018b423940b3bfe9fb43a4554b0e.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0001101011110011101110006069eb424ba67296ce0fc04598.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/00011101100000010010110139f5b44fd9a0e621833d1aee13.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0010000010100111111100003614aa4967ba89ae041f0e38b0.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0010011001110000001011102a722542f6b6d75a9ec3780b28.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/001001101011100101110000f74140432a9bbef6fc015f257a.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/001010100011110001001111ac0eac4de0b7cd675fbe903628.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0011000101100101101000101aa0d64489bc1af33569f24181.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0011010000100111100010109a4b594cdc9e262fffba9e6dfb.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0011010111100101101101015ea8d64b388ee54262477aa302.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0011100011111100000011114c92ce4b7ab294bc9f9d1c8f1b.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/001110111110100110110011d6d5c24f2ba2d8dc4fc53ad19e.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/01000101110110001100100158d35243779f0487ebf2aea87b.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/01000110000101011110110023d74b4d7588f4b14a99f70f4b.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/01000111000000010101000133cfbf419896d4f95aff35d1f3.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0100101010100101011100104167ad4e468f339405e4fe14eb.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/01010011100111000111111132f4674f8b997f39280a35ab20.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/010101101110010100111110dbfb234a12a81f4b2922feaa06.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0101101010111110000100109972c541a3b5f601c6ecd3fd00.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/010110110100111001111010a4bb294aca98fbe6762bee6a16.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/010110111110000000110011f49ba0400aadd03bb4c08110d2.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/010111110111010000000011d2312d48978ad987ba4d74be71.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/01100000101000011010010126d9c74aa39996faf925404aaa.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/011001000011110000000011f299124d76b7cf64273fb8b35c.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0110010111001101100110113ae089404cae00026c8ee24a62.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0110011001101100101100018559f648839905f283b8f1dcd0.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0110011010101111000001011c69ed49f499aabcef71033b65.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0110101001010001111010008f95634b78b462638b00c0b893.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0111001011110000101010014d572747dc99211c2b000ba5b0.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0111010111000000110100101969224108aa178dee856e14a4.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/0111011010111100111010118bb93f4093ae8d5d6cf6996514.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/100001001001110001101001feb81d49efa29cf3a436fe2d3c.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/1000011000101001111101110ff87f4797ab67a169c36af695.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/10011010010001110111000142dbe94fb89afc753338ae3aee.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/100111101010100000100110c9f79746b79427240b869184fd.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/101011011110110111101001e40a214249aa30ecdf9973e0c1.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/10101111111111111001100160de024fd9a8bb3420fe1e4fee.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/1011000010011011011001108a49f64844a7ca6faefaea3aeb.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/101101101100010001010111f9f04d4825b979ccb6376169b4.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/101110110010100100000011469a764e63b07cc627156f6e50.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/110000111100000110101100f527124a6fa88b045a73eb5bdd.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/110001100010010101011110fbb7664c83911abd9217656e94.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/11001110000101110010010065cbd54933870694c6ede2bcda.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/11101010111001100000001152614c44d599c95d4545832f1e.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/11101100001101111000001048d66d4bad92a65d5338d5930c.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/111011011100111111001110af633646cab7689fabb32510df.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/1110111100110100011110106a5e70498b95440aa3a698654b.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/111100001011111011101011e5464e45fc814cbc1cd6f15e44.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/1111000101110100000010002955a045ab8280b51125cf62f5.lance +0 -0
- package/vectorStore/uniapp_docs.lance/data/1111101110001000010101004110d448db8047d46e4eaa3744.lance +0 -0
- package/dist/index.d.mts +0 -80
- package/vectorStore/uniapp/args.json +0 -1
- package/vectorStore/uniapp/docstore.json +0 -1
- package/vectorStore/uniapp/hnswlib.index +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# UniAPP MCP
|
|
2
|
+
|
|
3
|
+
> 访问[uni-helper/skills](https://github.com/uni-helper/skills)获取`skills`。
|
|
4
|
+
|
|
5
|
+
使用 `MCP + RAG` 方案来查询 uniapp 文档。
|
|
2
6
|
|
|
3
7
|
## 安装
|
|
4
8
|
|
|
@@ -6,16 +10,20 @@
|
|
|
6
10
|
pnpm add @uni-helper/mcp -D
|
|
7
11
|
```
|
|
8
12
|
|
|
9
|
-
## 配置
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
## 配置 MCP 服务器
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"mcpServers": {
|
|
17
|
+
"uni-doc": {
|
|
18
|
+
"command": "uni-mcp"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
## 注意如果使用pnpm,请在`pnpm-workspace.yaml`中添加如下配置:
|
|
25
|
+
确保能正确构建`@uni-helper/mcp`插件
|
|
26
|
+
```yaml
|
|
27
|
+
onlyBuiltDependencies:
|
|
28
|
+
- '@uni-helper/mcp'
|
|
21
29
|
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { env } from "@huggingface/transformers";
|
|
4
|
+
import { connect } from "@lancedb/lancedb";
|
|
5
|
+
import { HuggingFaceTransformersEmbeddings } from "@langchain/community/embeddings/huggingface_transformers";
|
|
6
|
+
import { LanceDB } from "@langchain/community/vectorstores/lancedb";
|
|
7
|
+
|
|
8
|
+
//#region src/docs/index.ts
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
async function loadVectorStore(vectorName, _embeddings) {
|
|
11
|
+
const vectorMap = { uniapp: {
|
|
12
|
+
dir: join(__dirname, "../../", "vectorStore"),
|
|
13
|
+
tableName: "uniapp_docs"
|
|
14
|
+
} };
|
|
15
|
+
const vectorDir = vectorMap[vectorName].dir;
|
|
16
|
+
const table = await (await connect(vectorDir)).openTable(vectorMap[vectorName].tableName);
|
|
17
|
+
env.version = "master";
|
|
18
|
+
env.remoteHost = "https://www.modelscope.cn/models";
|
|
19
|
+
return new LanceDB(_embeddings ?? new HuggingFaceTransformersEmbeddings({
|
|
20
|
+
model: "onnx-community/Qwen3-Embedding-0.6B-ONNX",
|
|
21
|
+
pretrainedOptions: {
|
|
22
|
+
dtype: "int8",
|
|
23
|
+
device: "cpu"
|
|
24
|
+
}
|
|
25
|
+
}), {
|
|
26
|
+
table,
|
|
27
|
+
uri: vectorDir,
|
|
28
|
+
tableName: vectorMap[vectorName].tableName
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { loadVectorStore };
|
package/dist/index.mjs
CHANGED
|
@@ -1,424 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { serve } from "@hono/node-server";
|
|
5
|
-
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
6
|
-
import fkill from "fkill";
|
|
7
|
-
import { Hono } from "hono";
|
|
8
|
-
import { cors } from "hono/cors";
|
|
9
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
import { dirname, join } from "node:path";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
-
import { env } from "@huggingface/transformers";
|
|
14
|
-
import { HuggingFaceTransformersEmbeddings } from "@langchain/community/embeddings/huggingface_transformers";
|
|
15
|
-
import { HNSWLib } from "@langchain/community/vectorstores/hnswlib";
|
|
16
|
-
import fs from "fs-extra";
|
|
17
|
-
import { existsSync } from "node:fs";
|
|
18
|
-
import { homedir } from "node:os";
|
|
19
|
-
import consola from "consola";
|
|
20
|
-
import { Buffer as Buffer$1 } from "node:buffer";
|
|
21
|
-
import open from "open";
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createMcpServer } from "./server/index.mjs";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
22
4
|
|
|
23
|
-
//#region rolldown:runtime
|
|
24
|
-
var __create = Object.create;
|
|
25
|
-
var __defProp = Object.defineProperty;
|
|
26
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
27
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
28
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
29
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
30
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
31
|
-
var __copyProps = (to, from, except, desc) => {
|
|
32
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
33
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
34
|
-
key = keys[i];
|
|
35
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
36
|
-
__defProp(to, key, {
|
|
37
|
-
get: ((k) => from[k]).bind(null, key),
|
|
38
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return to;
|
|
44
|
-
};
|
|
45
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
46
|
-
value: mod,
|
|
47
|
-
enumerable: true
|
|
48
|
-
}) : target, mod));
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.cjs
|
|
52
|
-
var require_ansis = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
53
|
-
let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e) => {
|
|
54
|
-
let t = /([a-f\d]{3,6})/i.exec(e)?.[1], r = t?.length, l = parseInt(6 ^ r ? 3 ^ r ? "0" : t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, 16);
|
|
55
|
-
return [
|
|
56
|
-
l >> 16 & 255,
|
|
57
|
-
l >> 8 & 255,
|
|
58
|
-
255 & l
|
|
59
|
-
];
|
|
60
|
-
}, u = (e, t, r) => e ^ t || t ^ r ? 16 + 36 * c(e / 51) + 6 * c(t / 51) + c(r / 51) : 8 > e ? 16 : e > 248 ? 231 : c(24 * (e - 8) / 247) + 232, d = (e) => {
|
|
61
|
-
let t, r, l, n, o;
|
|
62
|
-
return 8 > e ? 30 + e : 16 > e ? e - 8 + 90 : (232 > e ? (o = (e -= 16) % 36, t = (e / 36 | 0) / 5, r = (o / 6 | 0) / 5, l = o % 6 / 5) : t = r = l = (10 * (e - 232) + 8) / 255, n = 2 * a(t, r, l), n ? 30 + (c(l) << 2 | c(r) << 1 | c(t)) + (2 ^ n ? 0 : 60) : 30);
|
|
63
|
-
}, f = (() => {
|
|
64
|
-
let r = (e) => o.some(((t) => e.test(t))), l = globalThis, n = l.process ?? {}, o = n.argv ?? [], i = n.env ?? {}, c = -1;
|
|
65
|
-
try {
|
|
66
|
-
e = "," + s(i).join(",");
|
|
67
|
-
} catch (e) {
|
|
68
|
-
i = {}, c = 0;
|
|
69
|
-
}
|
|
70
|
-
let a$1 = "FORCE_COLOR", p = {
|
|
71
|
-
false: 0,
|
|
72
|
-
0: 0,
|
|
73
|
-
1: 1,
|
|
74
|
-
2: 2,
|
|
75
|
-
3: 3
|
|
76
|
-
}[i[a$1]] ?? -1, u = a$1 in i && p || r(/^--color=?(true|always)?$/);
|
|
77
|
-
return u && (c = p), ~c || (c = ((r$1, l$1, n$1) => (t = r$1.TERM, {
|
|
78
|
-
"24bit": 3,
|
|
79
|
-
truecolor: 3,
|
|
80
|
-
ansi256: 2,
|
|
81
|
-
ansi: 1
|
|
82
|
-
}[r$1.COLORTERM] || (r$1.CI ? /,GITHUB/.test(e) ? 3 : 1 : l$1 && "dumb" !== t ? n$1 ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i, !!i.PM2_HOME || i.NEXT_RUNTIME?.includes("edge") || !!n.stdout?.isTTY, "win32" === n.platform)), !p || i.NO_COLOR || r(/^--(no-color|color=(false|never))$/) ? 0 : l.window?.chrome || u && !c ? 3 : c;
|
|
83
|
-
})(), g = {
|
|
84
|
-
open: i,
|
|
85
|
-
close: i
|
|
86
|
-
}, h = 39, b = 49, O = {}, m = ({ p: e }, { open: t, close: l }) => {
|
|
87
|
-
let o = (e$1, ...r) => {
|
|
88
|
-
if (!e$1) {
|
|
89
|
-
if (t && t === l) return t;
|
|
90
|
-
if ((e$1 ?? i) === i) return i;
|
|
91
|
-
}
|
|
92
|
-
let n, s$1 = e$1.raw ? String.raw({ raw: e$1 }, ...r) : i + e$1, c$1 = o.p, a$1 = c$1.o, p = c$1.c;
|
|
93
|
-
if (s$1.includes("\x1B")) for (; c$1; c$1 = c$1.p) {
|
|
94
|
-
let { open: e$2, close: t$1 } = c$1, r$1 = t$1.length, l$1 = i, o$1 = 0;
|
|
95
|
-
if (r$1) for (; ~(n = s$1.indexOf(t$1, o$1)); o$1 = n + r$1) l$1 += s$1.slice(o$1, n) + e$2;
|
|
96
|
-
s$1 = l$1 + s$1.slice(o$1);
|
|
97
|
-
}
|
|
98
|
-
return a$1 + (s$1.includes("\n") ? s$1.replace(/(\r?\n)/g, p + "$1" + a$1) : s$1) + p;
|
|
99
|
-
}, s = t, c = l;
|
|
100
|
-
return e && (s = e.o + t, c = l + e.c), n(o, r), o.p = {
|
|
101
|
-
open: t,
|
|
102
|
-
close: l,
|
|
103
|
-
o: s,
|
|
104
|
-
c,
|
|
105
|
-
p: e
|
|
106
|
-
}, o.open = s, o.close = c, o;
|
|
107
|
-
};
|
|
108
|
-
const w = new function e(t = f) {
|
|
109
|
-
let s = {
|
|
110
|
-
Ansis: e,
|
|
111
|
-
level: t,
|
|
112
|
-
isSupported: () => a$1,
|
|
113
|
-
strip: (e$1) => e$1.replace(/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
|
|
114
|
-
extend(e$1) {
|
|
115
|
-
for (let t$1 in e$1) {
|
|
116
|
-
let r = e$1[t$1], l = (typeof r)[0];
|
|
117
|
-
"s" === l ? (c(t$1, T(...p(r))), c(_(t$1), v(...p(r)))) : c(t$1, r, "f" === l);
|
|
118
|
-
}
|
|
119
|
-
return r = o({}, O), n(s, r), s;
|
|
120
|
-
}
|
|
121
|
-
}, c = (e$1, t$1, r) => {
|
|
122
|
-
O[e$1] = { get() {
|
|
123
|
-
let n = r ? (...e$2) => m(this, t$1(...e$2)) : m(this, t$1);
|
|
124
|
-
return l(this, e$1, { value: n }), n;
|
|
125
|
-
} };
|
|
126
|
-
}, a$1 = t > 0, w = (e$1, t$1) => a$1 ? {
|
|
127
|
-
open: `[${e$1}m`,
|
|
128
|
-
close: `[${t$1}m`
|
|
129
|
-
} : g, y = (e$1) => (t$1) => e$1(...p(t$1)), R = (e$1, t$1) => (r, l, n) => w(`${e$1}8;2;${r};${l};${n}`, t$1), $ = (e$1, t$1) => (r, l, n) => w(((e$2, t$2, r$1) => d(u(e$2, t$2, r$1)))(r, l, n) + e$1, t$1), x = (e$1) => (t$1, r, l) => e$1(u(t$1, r, l)), T = R(3, h), v = R(4, b), C = (e$1) => w("38;5;" + e$1, h), E = (e$1) => w("48;5;" + e$1, b);
|
|
130
|
-
2 === t ? (T = x(C), v = x(E)) : 1 === t && (T = $(0, h), v = $(10, b), C = (e$1) => w(d(e$1), h), E = (e$1) => w(d(e$1) + 10, b));
|
|
131
|
-
let M, I = {
|
|
132
|
-
fg: C,
|
|
133
|
-
bg: E,
|
|
134
|
-
rgb: T,
|
|
135
|
-
bgRgb: v,
|
|
136
|
-
hex: y(T),
|
|
137
|
-
bgHex: y(v),
|
|
138
|
-
visible: g,
|
|
139
|
-
reset: w(0, 0),
|
|
140
|
-
bold: w(1, 22),
|
|
141
|
-
dim: w(2, 22),
|
|
142
|
-
italic: w(3, 23),
|
|
143
|
-
underline: w(4, 24),
|
|
144
|
-
inverse: w(7, 27),
|
|
145
|
-
hidden: w(8, 28),
|
|
146
|
-
strikethrough: w(9, 29)
|
|
147
|
-
}, _ = (e$1) => "bg" + e$1[0].toUpperCase() + e$1.slice(1), k = "Bright";
|
|
148
|
-
return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e$1, t$1) => {
|
|
149
|
-
M = _(e$1), 8 > t$1 ? (I[e$1 + k] = w(90 + t$1, h), I[M + k] = w(100 + t$1, b)) : t$1 = 60, I[e$1] = w(30 + t$1, h), I[M] = w(40 + t$1, b);
|
|
150
|
-
})), s.extend(I);
|
|
151
|
-
}();
|
|
152
|
-
module.exports = w, w.default = w;
|
|
153
|
-
}));
|
|
154
|
-
|
|
155
|
-
//#endregion
|
|
156
|
-
//#region node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
|
|
157
|
-
var import_ansis = /* @__PURE__ */ __toESM(require_ansis(), 1);
|
|
158
|
-
var ansis_default = import_ansis.default;
|
|
159
|
-
const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
|
|
160
|
-
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/mcpServer/connect.ts
|
|
163
|
-
function connectServer(server, options) {
|
|
164
|
-
const { port = 2515, printUrl = true } = options;
|
|
165
|
-
const transport = new WebStandardStreamableHTTPServerTransport();
|
|
166
|
-
const app = new Hono();
|
|
167
|
-
app.use("*", cors({
|
|
168
|
-
origin: "*",
|
|
169
|
-
allowMethods: [
|
|
170
|
-
"GET",
|
|
171
|
-
"POST",
|
|
172
|
-
"DELETE",
|
|
173
|
-
"OPTIONS"
|
|
174
|
-
],
|
|
175
|
-
allowHeaders: [
|
|
176
|
-
"Content-Type",
|
|
177
|
-
"mcp-session-id",
|
|
178
|
-
"Last-Event-ID",
|
|
179
|
-
"mcp-protocol-version"
|
|
180
|
-
],
|
|
181
|
-
exposeHeaders: ["mcp-session-id", "mcp-protocol-version"]
|
|
182
|
-
}));
|
|
183
|
-
app.all("/mcp", (c) => transport.handleRequest(c.req.raw));
|
|
184
|
-
fkill(port, {
|
|
185
|
-
force: true,
|
|
186
|
-
silent: true
|
|
187
|
-
}).then(() => {
|
|
188
|
-
server.connect(transport).then(() => {
|
|
189
|
-
if (printUrl) console.log(`${ansis_default.cyan` ➜ MCP: `}${ansis_default.gray(`server is running at ${ansis_default.green(`http://localhost:${port}/mcp`)}`)}`);
|
|
190
|
-
serve({
|
|
191
|
-
fetch: app.fetch,
|
|
192
|
-
port
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
return `http://localhost:${port}/mcp`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/docs/index.ts
|
|
201
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
202
|
-
async function loadVectorStore(vectorName, _embeddings) {
|
|
203
|
-
const vectorDirMap = { uniapp: join(__dirname, "../", "vectorStore", "uniapp") };
|
|
204
|
-
env.version = "master";
|
|
205
|
-
env.remoteHost = "https://www.modelscope.cn/models";
|
|
206
|
-
const embeddings = _embeddings ?? new HuggingFaceTransformersEmbeddings({
|
|
207
|
-
model: "onnx-community/Qwen3-Embedding-0.6B-ONNX",
|
|
208
|
-
pretrainedOptions: {
|
|
209
|
-
dtype: "int8",
|
|
210
|
-
device: "cpu"
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
return await HNSWLib.load(vectorDirMap[vectorName], embeddings);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
//#endregion
|
|
217
|
-
//#region package.json
|
|
218
|
-
var version = "0.0.2-beta.2";
|
|
219
|
-
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/mcpServer/projectAnalyzer.ts
|
|
222
|
-
async function readFileIfExists(path) {
|
|
223
|
-
const content = await fs.readFile(path, "utf-8").catch(() => void 0);
|
|
224
|
-
return {
|
|
225
|
-
exists: !!content,
|
|
226
|
-
path,
|
|
227
|
-
content
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
async function analyzeProject(rootPath) {
|
|
231
|
-
const [pagesJson, manifestJson] = await Promise.all([readFileIfExists(join(rootPath, "src/pages.json")), readFileIfExists(join(rootPath, "src/manifest.json"))]);
|
|
232
|
-
return {
|
|
233
|
-
pagesJson,
|
|
234
|
-
manifestJson
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region src/mcpServer/server.ts
|
|
240
|
-
async function createMcpServer(config, options) {
|
|
241
|
-
const server = new McpServer({
|
|
242
|
-
name: "uni",
|
|
243
|
-
version
|
|
244
|
-
});
|
|
245
|
-
server.registerTool("get-vite-config", {
|
|
246
|
-
title: "获取 Vite 配置",
|
|
247
|
-
description: "获取 Vite 配置摘要,包括根目录、解析配置、插件和环境名称。"
|
|
248
|
-
}, () => ({ content: [{
|
|
249
|
-
type: "text",
|
|
250
|
-
text: JSON.stringify({
|
|
251
|
-
root: config.root,
|
|
252
|
-
resolve: config.resolve,
|
|
253
|
-
plugins: config.plugins.map((p) => p.name).filter(Boolean),
|
|
254
|
-
environmentNames: Object.keys(config.environments)
|
|
255
|
-
})
|
|
256
|
-
}] }));
|
|
257
|
-
server.registerTool("search-docs-by-Uniapp-official", {
|
|
258
|
-
title: "搜索 Uniapp 官方文档",
|
|
259
|
-
description: "在 Uniapp 文档知识库中进行搜索,可查找相关信息、代码示例、API参考文档和操作指南。当您需要解答关于Uniapp文档的问题、查找特定文档内容、了解功能运作原理或定位实现细节时,可使用此工具。搜索结果将返回带有标题的上下文相关内容,并附有直达文档页面的链接。",
|
|
260
|
-
inputSchema: { query: z.string().describe("用于搜索内容的查询语句") }
|
|
261
|
-
}, async ({ query }) => {
|
|
262
|
-
return { content: (await (await loadVectorStore("uniapp", options.embeddings)).similaritySearch(query, 3)).map((doc) => ({
|
|
263
|
-
type: "text",
|
|
264
|
-
text: JSON.stringify(doc)
|
|
265
|
-
})) };
|
|
266
|
-
});
|
|
267
|
-
server.registerTool("get-project-overview", {
|
|
268
|
-
title: "获取项目概览",
|
|
269
|
-
description: "返回 Uniapp 项目的 pages.json 和 manifest.json 配置文件。"
|
|
270
|
-
}, async () => {
|
|
271
|
-
const overview = await analyzeProject(config.root);
|
|
272
|
-
return { content: [{
|
|
273
|
-
type: "text",
|
|
274
|
-
text: JSON.stringify(overview, null, 2)
|
|
275
|
-
}] };
|
|
276
|
-
});
|
|
277
|
-
return server;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/updateConfigs/claude.ts
|
|
282
|
-
async function updateClaudeConfig(root, sseUrl, _options) {
|
|
283
|
-
const mcp = existsSync(join(root, ".mcp.json")) ? JSON.parse(await fs.readFile(join(root, ".mcp.json"), "utf-8") || "{}") : {};
|
|
284
|
-
mcp.mcpServers ||= {};
|
|
285
|
-
mcp.mcpServers.uni = {
|
|
286
|
-
type: "http",
|
|
287
|
-
url: sseUrl
|
|
288
|
-
};
|
|
289
|
-
await fs.writeFile(join(root, ".mcp.json"), `${JSON.stringify(mcp, null, 2)}\n`);
|
|
290
|
-
consola.log(`${CONSOLE_LOG_PREFIX}${ansis_default.gray(`Updated config file ${join(root, ".mcp.json")}`)}`);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region src/updateConfigs/cursor.ts
|
|
295
|
-
async function updateCursorConfig(root, sseUrl, _options) {
|
|
296
|
-
await fs.mkdir(join(root, ".cursor"), { recursive: true });
|
|
297
|
-
const mcp = existsSync(join(root, ".cursor/mcp.json")) ? JSON.parse(await fs.readFile(join(root, ".cursor/mcp.json"), "utf-8") || "{}") : {};
|
|
298
|
-
mcp.mcpServers ||= {};
|
|
299
|
-
mcp.mcpServers.uni = { url: sseUrl };
|
|
300
|
-
await fs.writeFile(join(root, ".cursor/mcp.json"), `${JSON.stringify(mcp, null, 2)}\n`);
|
|
301
|
-
consola.log(`${CONSOLE_LOG_PREFIX}${ansis_default.gray(`Updated config file ${join(root, ".cursor/mcp.json")}`)}`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region src/updateConfigs/print.ts
|
|
306
|
-
function mcpServersConfig(sseUrl) {
|
|
307
|
-
const code = ansis_default.rgb(206, 145, 120);
|
|
308
|
-
const purple = ansis_default.rgb(218, 112, 214);
|
|
309
|
-
return `
|
|
310
|
-
${ansis_default.yellow`{`}
|
|
311
|
-
${code`"mcpServers"`}${ansis_default.white`:`} ${purple`{`}
|
|
312
|
-
${code`"uni"`}${ansis_default.white`:`} ${ansis_default.blue`{`}
|
|
313
|
-
${code`"url"`}${ansis_default.white`:`} ${code`"${sseUrl}"`}
|
|
314
|
-
${ansis_default.blue`}`}
|
|
315
|
-
${purple`}`}
|
|
316
|
-
${ansis_default.yellow`}`}
|
|
317
|
-
`;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region src/updateConfigs/trae.ts
|
|
322
|
-
async function updateTraeConfig(sseUrl, _options) {
|
|
323
|
-
await open(`trae://trae.ai-ide/mcp-import?type=http&name=uni&config=${Buffer$1.from(JSON.stringify({ url: sseUrl })).toString("base64")}`);
|
|
324
|
-
consola.log(`${CONSOLE_LOG_PREFIX}${ansis_default.gray(`自动配置了trae链接,请在trae中确认`)}`);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/updateConfigs/trae-cn.ts
|
|
329
|
-
async function updateTraeCNConfig(sseUrl, _options) {
|
|
330
|
-
await open(`trae-cn://trae.ai-ide/mcp-import?type=http&name=uni&config=${Buffer$1.from(JSON.stringify({ url: sseUrl })).toString("base64")}`);
|
|
331
|
-
consola.log(`${CONSOLE_LOG_PREFIX}${ansis_default.gray(`自动配置了trae-cn链接,请在trae-cn中确认`)}`);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
//#endregion
|
|
335
|
-
//#region src/updateConfigs/vscode.ts
|
|
336
|
-
async function updateVSCodeConfig(root, sseUrl, _options) {
|
|
337
|
-
await fs.mkdir(join(root, ".vscode"), { recursive: true });
|
|
338
|
-
const mcp = existsSync(join(root, ".vscode/mcp.json")) ? JSON.parse(await fs.readFile(join(root, ".vscode/mcp.json"), "utf-8") || "{}") : {};
|
|
339
|
-
mcp.servers ||= {};
|
|
340
|
-
mcp.servers.uni = {
|
|
341
|
-
type: "http",
|
|
342
|
-
url: sseUrl
|
|
343
|
-
};
|
|
344
|
-
await fs.writeFile(join(root, ".vscode/mcp.json"), `${JSON.stringify(mcp, null, 2)}\n`);
|
|
345
|
-
consola.log(`${CONSOLE_LOG_PREFIX}${ansis_default.gray(`Updated config file ${join(root, ".vscode/mcp.json")}`)}`);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
//#endregion
|
|
349
|
-
//#region src/updateConfigs/windsurf.ts
|
|
350
|
-
async function updateWindsurfConfig(sseUrl, _options) {
|
|
351
|
-
const windsurfDir = join(homedir(), ".codeium", "windsurf");
|
|
352
|
-
const windsurfConfigPath = join(windsurfDir, "mcp_config.json");
|
|
353
|
-
try {
|
|
354
|
-
await fs.mkdir(windsurfDir, { recursive: true });
|
|
355
|
-
const config = existsSync(windsurfConfigPath) ? JSON.parse(await fs.readFile(windsurfConfigPath, "utf-8").catch(() => "{}") || "{}") : {};
|
|
356
|
-
config.mcpServers ||= {};
|
|
357
|
-
config.mcpServers.uni = { serverUrl: sseUrl };
|
|
358
|
-
await fs.writeFile(windsurfConfigPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
359
|
-
consola.log(`${CONSOLE_LOG_PREFIX}${ansis_default.gray(`Updated config file ${windsurfConfigPath}`)}`);
|
|
360
|
-
} catch (e) {
|
|
361
|
-
consola.error(`${CONSOLE_LOG_PREFIX}${ansis_default.red(`Failed to update ${windsurfConfigPath}`)}${e}`);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region src/updateConfigs/index.ts
|
|
367
|
-
const CONSOLE_LOG_PREFIX = ansis_default.cyan.bold`[MCP] `;
|
|
368
|
-
async function updateConfigs(root, sseUrl, options) {
|
|
369
|
-
const { updateConfig = false } = options;
|
|
370
|
-
if (updateConfig === false) {
|
|
371
|
-
consola.log(`${CONSOLE_LOG_PREFIX}请手动配置mcpServers`);
|
|
372
|
-
consola.box(mcpServersConfig(sseUrl));
|
|
373
|
-
}
|
|
374
|
-
const configPromises = (updateConfig === "auto" ? [
|
|
375
|
-
existsSync(join(root, ".cursor")) ? "cursor" : null,
|
|
376
|
-
existsSync(join(root, ".vscode")) ? "vscode" : null,
|
|
377
|
-
existsSync(join(homedir(), ".codeium", "windsurf")) ? "windsurf" : null,
|
|
378
|
-
existsSync(join(root, ".mcp.json")) ? "claude-code" : null,
|
|
379
|
-
existsSync(join(homedir(), ".trae-cn")) ? "trae-cn" : null,
|
|
380
|
-
existsSync(join(homedir(), ".trae")) ? "trae" : null
|
|
381
|
-
].filter((x) => x !== null) : Array.isArray(updateConfig) ? updateConfig : []).map(async (config) => {
|
|
382
|
-
switch (config) {
|
|
383
|
-
case "cursor":
|
|
384
|
-
await updateCursorConfig(root, sseUrl, options);
|
|
385
|
-
break;
|
|
386
|
-
case "vscode":
|
|
387
|
-
await updateVSCodeConfig(root, sseUrl, options);
|
|
388
|
-
break;
|
|
389
|
-
case "windsurf":
|
|
390
|
-
await updateWindsurfConfig(sseUrl, options);
|
|
391
|
-
break;
|
|
392
|
-
case "claude-code":
|
|
393
|
-
await updateClaudeConfig(root, sseUrl, options);
|
|
394
|
-
break;
|
|
395
|
-
case "trae-cn":
|
|
396
|
-
await updateTraeCNConfig(sseUrl, options);
|
|
397
|
-
break;
|
|
398
|
-
case "trae":
|
|
399
|
-
await updateTraeConfig(sseUrl, options);
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
await Promise.all(configPromises);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
//#endregion
|
|
407
5
|
//#region src/index.ts
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (isBuild()) return;
|
|
413
|
-
return {
|
|
414
|
-
name: "uni-mcp",
|
|
415
|
-
enforce: "post",
|
|
416
|
-
async configResolved(config) {
|
|
417
|
-
const url = connectServer(await createMcpServer(config, options), options);
|
|
418
|
-
await updateConfigs(searchForWorkspaceRoot(config.root), url, options);
|
|
419
|
-
}
|
|
420
|
-
};
|
|
6
|
+
async function main() {
|
|
7
|
+
const server = await createMcpServer();
|
|
8
|
+
const transport = new StdioServerTransport();
|
|
9
|
+
await server.connect(transport);
|
|
421
10
|
}
|
|
11
|
+
main().catch(console.error);
|
|
422
12
|
|
|
423
13
|
//#endregion
|
|
424
|
-
export {
|
|
14
|
+
export { };
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { version } from "../package.mjs";
|
|
2
|
+
import { loadVectorStore } from "../docs/index.mjs";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/server/index.ts
|
|
7
|
+
async function createMcpServer() {
|
|
8
|
+
const server = new McpServer({
|
|
9
|
+
name: "uni",
|
|
10
|
+
version
|
|
11
|
+
});
|
|
12
|
+
server.registerTool("search-docs-by-Uniapp-official", {
|
|
13
|
+
title: "搜索 Uniapp 官方文档",
|
|
14
|
+
description: "在 Uniapp 文档知识库中进行搜索,可查找相关信息、代码示例、API参考文档和操作指南。当您需要解答关于Uniapp文档的问题、查找特定文档内容、了解功能运作原理或定位实现细节时,可使用此工具。搜索结果将返回带有标题的上下文相关内容,并附有直达文档页面的链接。",
|
|
15
|
+
inputSchema: { query: z.string().describe("用于搜索内容的查询语句") }
|
|
16
|
+
}, async ({ query }) => {
|
|
17
|
+
return { content: (await (await loadVectorStore("uniapp")).similaritySearch(query, 3)).map((doc) => ({
|
|
18
|
+
type: "text",
|
|
19
|
+
text: JSON.stringify(doc)
|
|
20
|
+
})) };
|
|
21
|
+
});
|
|
22
|
+
return server;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { createMcpServer };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni-helper/mcp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.0.5",
|
|
5
|
+
"description": "为uniapp提供ai开发体验",
|
|
6
6
|
"author": "FliPPeDround <flippedround@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://afdian.com/a/flippedround",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"uni-app",
|
|
18
18
|
"uni-helper",
|
|
19
19
|
"mcp",
|
|
20
|
+
"ai",
|
|
21
|
+
"agent",
|
|
20
22
|
"miniapp"
|
|
21
23
|
],
|
|
22
24
|
"sideEffects": false,
|
|
@@ -28,31 +30,29 @@
|
|
|
28
30
|
},
|
|
29
31
|
"main": "./dist/index.mjs",
|
|
30
32
|
"module": "./dist/index.mjs",
|
|
31
|
-
"
|
|
33
|
+
"bin": {
|
|
34
|
+
"uni-mcp": "./dist/index.mjs"
|
|
35
|
+
},
|
|
32
36
|
"files": [
|
|
33
37
|
"dist",
|
|
34
38
|
"scripts",
|
|
35
39
|
"vectorStore"
|
|
36
40
|
],
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"uniapp": "*",
|
|
39
|
-
"vite": ">=3.1.0"
|
|
40
|
-
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@hono/node-server": "^1.19.9",
|
|
43
42
|
"@huggingface/transformers": "^3.8.1",
|
|
43
|
+
"@lancedb/lancedb": "0.22.3",
|
|
44
44
|
"@langchain/community": "^1.1.4",
|
|
45
45
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
46
|
+
"cac": "^6.7.14",
|
|
47
|
+
"commander": "^14.0.2",
|
|
46
48
|
"consola": "^3.2.3",
|
|
47
|
-
"fkill": "^10.0.3",
|
|
48
49
|
"fs-extra": "^11.3.3",
|
|
49
|
-
"hnswlib-node": "^3.0.0",
|
|
50
|
-
"hono": "^4.11.4",
|
|
51
50
|
"langchain": "^1.2.8",
|
|
52
51
|
"local-pkg": "^1.1.2",
|
|
53
52
|
"minimist": "^1.2.8",
|
|
54
53
|
"open": "^11.0.0",
|
|
55
54
|
"pathe": "^2.0.3",
|
|
55
|
+
"which": "^6.0.0",
|
|
56
56
|
"zod": "^4.3.5"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
@@ -79,7 +79,6 @@
|
|
|
79
79
|
"tsx": "^4.21.0",
|
|
80
80
|
"turndown": "^7.2.2",
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
|
-
"vite": "^7.3.1",
|
|
83
82
|
"vitest": "^4.0.17",
|
|
84
83
|
"vitest-package-exports": "^1.1.2"
|
|
85
84
|
},
|
|
@@ -93,12 +92,13 @@
|
|
|
93
92
|
"build": "tsdown",
|
|
94
93
|
"dev": "tsdown --watch ./src",
|
|
95
94
|
"lint": "eslint",
|
|
96
|
-
"task": "
|
|
95
|
+
"task": "node ./tasks/uniappDocs/index.ts",
|
|
97
96
|
"play": "cd playground && pnpm dev",
|
|
98
97
|
"lint:fix": "eslint --fix",
|
|
99
98
|
"inspect": "mcp-inspector",
|
|
100
99
|
"release": "bumpp",
|
|
100
|
+
"pull:repo": "node scripts/cli.ts",
|
|
101
101
|
"test": "vitest",
|
|
102
|
-
"postinstall": "node scripts/download-model.mjs"
|
|
102
|
+
"postinstall": "node scripts/download-model.mjs && node scripts/link-global.mjs"
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -2,10 +2,13 @@ import process from 'node:process'
|
|
|
2
2
|
import { env } from '@huggingface/transformers'
|
|
3
3
|
import { HuggingFaceTransformersEmbeddings } from '@langchain/community/embeddings/huggingface_transformers'
|
|
4
4
|
|
|
5
|
+
if (process.env.CI) {
|
|
6
|
+
process.exit(0)
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
async function downloadModel() {
|
|
6
10
|
env.version = 'master'
|
|
7
11
|
env.remoteHost = 'https://www.modelscope.cn/models'
|
|
8
|
-
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
9
12
|
const embeddings = new HuggingFaceTransformersEmbeddings({
|
|
10
13
|
model: 'onnx-community/Qwen3-Embedding-0.6B-ONNX',
|
|
11
14
|
pretrainedOptions: {
|