doc2vec 1.0.5 → 1.1.1
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/Dockerfile +19 -1
- package/README.md +6 -2
- package/config.yaml +3 -0
- package/dist/doc2vec.js +49 -1
- package/dist/logger.js +19 -3
- package/doc2vec.ts +59 -3
- package/logger.ts +287 -0
- package/mcp/Dockerfile +14 -0
- package/mcp/README.md +166 -0
- package/mcp/package-lock.json +1754 -0
- package/mcp/package.json +41 -0
- package/mcp/src/index.ts +214 -0
- package/mcp/tsconfig.json +16 -0
- package/package.json +3 -3
package/mcp/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# SQLite Vector Documentation Query MCP Server
|
|
2
|
+
|
|
3
|
+
This is a Model Context Protocol (MCP) server that enables querying documentation stored in SQLite databases with vector embeddings. The server uses OpenAI's embedding API to convert natural language queries into vector embeddings and performs semantic search against documentation stored in SQLite databases.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Vector-based semantic search for documentation
|
|
8
|
+
- Filters by product name and version
|
|
9
|
+
- Uses OpenAI's embedding API for query embedding generation
|
|
10
|
+
- Fully compatible with the Model Context Protocol
|
|
11
|
+
- Simple Express-based API with Server-Sent Events (SSE) for real-time communication
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js 20 or higher
|
|
16
|
+
- OpenAI API key
|
|
17
|
+
- Documentation stored in SQLite vector databases (using `sqlite-vec`)
|
|
18
|
+
|
|
19
|
+
## Environment Variables
|
|
20
|
+
|
|
21
|
+
| Variable | Description | Default |
|
|
22
|
+
|----------|-------------|---------|
|
|
23
|
+
| `OPENAI_API_KEY` | Your OpenAI API key (required) | - |
|
|
24
|
+
| `SQLITE_DB_DIR` | Directory containing SQLite databases | Current directory |
|
|
25
|
+
| `PORT` | Port to run the server on | 3001 |
|
|
26
|
+
|
|
27
|
+
## Local Setup and Running
|
|
28
|
+
|
|
29
|
+
1. Install dependencies:
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Create a `.env` file with required environment variables:
|
|
35
|
+
```
|
|
36
|
+
OPENAI_API_KEY=your_openai_api_key
|
|
37
|
+
SQLITE_DB_DIR=/path/to/databases
|
|
38
|
+
PORT=3001
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. Build the TypeScript code:
|
|
42
|
+
```bash
|
|
43
|
+
npm run build
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
4. Start the server:
|
|
47
|
+
```bash
|
|
48
|
+
npm start
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Docker Setup
|
|
52
|
+
|
|
53
|
+
### Building the Docker Image
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
docker build -t sqlite-vec-mcp-server:latest .
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This is going to include any `*.db` files in the `/data` directory of the image.
|
|
60
|
+
|
|
61
|
+
### Running with Docker
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
docker run -p 3001:3001 \
|
|
65
|
+
-e OPENAI_API_KEY=your_openai_api_key \
|
|
66
|
+
sqlite-vec-mcp-server:latest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Create a Secret for the OpenAI API Key
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
kubectl create secret generic mcp-secrets \
|
|
73
|
+
--from-literal=OPENAI_API_KEY=your_openai_api_key
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Create a ConfigMap for Database Configuration
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
kubectl create configmap mcp-config \
|
|
80
|
+
--from-literal=SQLITE_DB_DIR=/data \
|
|
81
|
+
--from-literal=PORT=3001
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Create a Deployment
|
|
85
|
+
|
|
86
|
+
Create a file named `deployment.yaml`:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
apiVersion: apps/v1
|
|
90
|
+
kind: Deployment
|
|
91
|
+
metadata:
|
|
92
|
+
name: mcp-sqlite-vec
|
|
93
|
+
labels:
|
|
94
|
+
app: mcp-sqlite-vec
|
|
95
|
+
spec:
|
|
96
|
+
replicas: 1
|
|
97
|
+
selector:
|
|
98
|
+
matchLabels:
|
|
99
|
+
app: mcp-sqlite-vec
|
|
100
|
+
template:
|
|
101
|
+
metadata:
|
|
102
|
+
labels:
|
|
103
|
+
app: mcp-sqlite-vec
|
|
104
|
+
spec:
|
|
105
|
+
containers:
|
|
106
|
+
- name: mcp-sqlite-vec
|
|
107
|
+
image: sqlite-vec-mcp-server:latest
|
|
108
|
+
imagePullPolicy: Always
|
|
109
|
+
ports:
|
|
110
|
+
- containerPort: 3001
|
|
111
|
+
env:
|
|
112
|
+
- name: OPENAI_API_KEY
|
|
113
|
+
valueFrom:
|
|
114
|
+
secretKeyRef:
|
|
115
|
+
name: mcp-secrets
|
|
116
|
+
key: OPENAI_API_KEY
|
|
117
|
+
- name: SQLITE_DB_DIR
|
|
118
|
+
valueFrom:
|
|
119
|
+
configMapKeyRef:
|
|
120
|
+
name: mcp-config
|
|
121
|
+
key: SQLITE_DB_DIR
|
|
122
|
+
- name: PORT
|
|
123
|
+
valueFrom:
|
|
124
|
+
configMapKeyRef:
|
|
125
|
+
name: mcp-config
|
|
126
|
+
key: PORT
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Apply it:
|
|
130
|
+
```bash
|
|
131
|
+
kubectl apply -f deployment.yaml
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Create a Service
|
|
135
|
+
|
|
136
|
+
Create a file named `service.yaml`:
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
apiVersion: v1
|
|
140
|
+
kind: Service
|
|
141
|
+
metadata:
|
|
142
|
+
name: mcp-sqlite-vec
|
|
143
|
+
spec:
|
|
144
|
+
selector:
|
|
145
|
+
app: mcp-sqlite-vec
|
|
146
|
+
ports:
|
|
147
|
+
- port: 3001
|
|
148
|
+
targetPort: 3001
|
|
149
|
+
type: ClusterIP
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Apply it:
|
|
153
|
+
```bash
|
|
154
|
+
kubectl apply -f service.yaml
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Using the MCP Server
|
|
158
|
+
|
|
159
|
+
The server implements a tool called `query-documentation` that can be used to query documentation.
|
|
160
|
+
|
|
161
|
+
### Tool Parameters
|
|
162
|
+
|
|
163
|
+
- `queryText` (string, required): The natural language query to search for
|
|
164
|
+
- `productName` (string, required): The name of the product documentation database to search within
|
|
165
|
+
- `version` (string, optional): The specific version of the product documentation
|
|
166
|
+
- `limit` (number, optional, default: 4): Maximum number of results to return
|