graph.do 0.1.0
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/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/chunk-SOVFPCTE.js +647 -0
- package/dist/chunk-SOVFPCTE.js.map +1 -0
- package/dist/chunk-VXRM2HKS.js +203 -0
- package/dist/chunk-VXRM2HKS.js.map +1 -0
- package/dist/cli/index.js +724 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index-BmsgR5Vk.d.ts +257 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +15 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/worker/index.d.ts +15 -0
- package/dist/worker/index.js +56 -0
- package/dist/worker/index.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nathan Clevenger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# graph.do
|
|
2
|
+
|
|
3
|
+
Knowledge graph database built on [mongo.do](https://github.com/drivly/mongo.do) with [MCP](https://modelcontextprotocol.io) server support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install graph.do
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { graph } from 'graph.do'
|
|
15
|
+
|
|
16
|
+
// Create entities
|
|
17
|
+
await graph.createEntities([
|
|
18
|
+
{ name: 'Alice', entityType: 'Person', observations: ['Works at Acme', 'Lives in NYC'] },
|
|
19
|
+
{ name: 'Bob', entityType: 'Person', observations: ['Works at Acme', 'Manages Alice'] },
|
|
20
|
+
{ name: 'Acme', entityType: 'Company', observations: ['Tech startup', 'Founded 2020'] }
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
// Create relations
|
|
24
|
+
await graph.createRelations([
|
|
25
|
+
{ from: 'Alice', to: 'Acme', relationType: 'works_at' },
|
|
26
|
+
{ from: 'Bob', to: 'Acme', relationType: 'works_at' },
|
|
27
|
+
{ from: 'Bob', to: 'Alice', relationType: 'manages' }
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
// Search the graph
|
|
31
|
+
const results = await graph.searchNodes('Acme')
|
|
32
|
+
|
|
33
|
+
// Read the entire graph
|
|
34
|
+
const fullGraph = await graph.readGraph()
|
|
35
|
+
|
|
36
|
+
// Open specific nodes with their relations
|
|
37
|
+
const nodes = await graph.openNodes(['Alice', 'Bob'])
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
### Entities
|
|
43
|
+
|
|
44
|
+
Entities are nodes in the knowledge graph with:
|
|
45
|
+
- `name` - Unique identifier
|
|
46
|
+
- `entityType` - Classification (Person, Company, etc.)
|
|
47
|
+
- `observations` - Array of facts about the entity
|
|
48
|
+
|
|
49
|
+
### Relations
|
|
50
|
+
|
|
51
|
+
Relations are directed edges between entities:
|
|
52
|
+
- `from` - Source entity name
|
|
53
|
+
- `to` - Target entity name
|
|
54
|
+
- `relationType` - Type of relationship (in active voice)
|
|
55
|
+
|
|
56
|
+
### Methods
|
|
57
|
+
|
|
58
|
+
| Method | Description |
|
|
59
|
+
|--------|-------------|
|
|
60
|
+
| `createEntities(entities)` | Create new entities (skips duplicates) |
|
|
61
|
+
| `createRelations(relations)` | Create new relations (skips duplicates) |
|
|
62
|
+
| `addObservations(observations)` | Add observations to existing entities |
|
|
63
|
+
| `deleteEntities(names)` | Delete entities and their relations |
|
|
64
|
+
| `deleteObservations(deletions)` | Remove specific observations |
|
|
65
|
+
| `deleteRelations(relations)` | Remove specific relations |
|
|
66
|
+
| `readGraph()` | Get the complete graph |
|
|
67
|
+
| `searchNodes(query)` | Search by name, type, or observation |
|
|
68
|
+
| `openNodes(names)` | Get specific entities with inter-relations |
|
|
69
|
+
|
|
70
|
+
## MCP Server
|
|
71
|
+
|
|
72
|
+
graph.do includes a Model Context Protocol server for AI agent integration.
|
|
73
|
+
|
|
74
|
+
### CLI (stdio transport)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Uses https://graph.do by default
|
|
78
|
+
npx graph.do
|
|
79
|
+
|
|
80
|
+
# Or with custom URL
|
|
81
|
+
npx graph.do --url https://my-graph.workers.dev
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Add to Claude Desktop config:
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"graph": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["graph.do"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### HTTP Transport
|
|
97
|
+
|
|
98
|
+
Deploy to Cloudflare Workers for HTTP MCP access:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run deploy
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Endpoints:
|
|
105
|
+
- `GET /mcp` - Server info
|
|
106
|
+
- `GET /mcp/tools` - List available tools
|
|
107
|
+
- `POST /mcp` - JSON-RPC endpoint
|
|
108
|
+
- `POST /mcp/tools/:name` - Direct tool calls
|
|
109
|
+
|
|
110
|
+
## Custom Deployment
|
|
111
|
+
|
|
112
|
+
graph.do is self-contained - deploy your own instance:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
git clone https://github.com/drivly/graph.do
|
|
116
|
+
cd graph.do
|
|
117
|
+
npm install
|
|
118
|
+
npm run deploy
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Or use a custom URL programmatically:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { createGraph } from 'graph.do'
|
|
125
|
+
|
|
126
|
+
const graph = createGraph('https://my-graph.workers.dev')
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Architecture
|
|
130
|
+
|
|
131
|
+
graph.do is built on:
|
|
132
|
+
- **[mongo.do](https://github.com/drivly/mongo.do)** - MongoDB-compatible database on Cloudflare Durable Objects
|
|
133
|
+
- **SQLite** - Persistent storage via Durable Objects
|
|
134
|
+
- **MCP** - Model Context Protocol for AI integration
|
|
135
|
+
|
|
136
|
+
Data is stored in two collections:
|
|
137
|
+
- `entities` - Graph nodes
|
|
138
|
+
- `relations` - Graph edges
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
MIT
|