@kubun/mcp 0.7.0 → 0.8.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/lib/client.d.ts +3 -3
- package/lib/client.js +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.js +1 -1
- package/lib/container.d.ts +2 -2
- package/lib/container.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/run.js +1 -1
- package/lib/tools/cluster.js +1 -1
- package/lib/tools/connection.js +1 -1
- package/lib/tools/graph.js +1 -1
- package/package.json +12 -13
package/lib/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SigningIdentity } from '@enkaku/token';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GraphsProvider } from '@kubun/protocol';
|
|
3
3
|
export type ClientConfig = {
|
|
4
4
|
type: 'memory';
|
|
5
5
|
} | {
|
|
@@ -17,10 +17,10 @@ export type ClientParams = ClientConfig & {
|
|
|
17
17
|
identity?: SigningIdentity;
|
|
18
18
|
};
|
|
19
19
|
export type ClientConnection = {
|
|
20
|
-
|
|
20
|
+
provider: GraphsProvider;
|
|
21
21
|
dispose: () => Promise<void>;
|
|
22
22
|
type: ClientConfig['type'];
|
|
23
23
|
address: string;
|
|
24
24
|
};
|
|
25
25
|
export declare function parseDatabase(database: string): ClientConfig;
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function createConnection(params: ClientParams): Promise<ClientConnection>;
|
package/lib/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomIdentity as t}from"@enkaku/token";import{KubunDB as e}from"@kubun/db";import{NodeSQLiteAdapter as r}from"@kubun/db-node-sqlite";import{PostgresAdapter as
|
|
1
|
+
import{randomIdentity as t}from"@enkaku/token";import{KubunDB as e}from"@kubun/db";import{NodeSQLiteAdapter as r}from"@kubun/db-node-sqlite";import{PostgresAdapter as p}from"@kubun/db-postgres";import{KubunEngine as s}from"@kubun/engine";import{HTTPClient as o}from"@kubun/http-client";export function parseDatabase(t){return t.startsWith("http://")||t.startsWith("https://")?{type:"http",url:t}:t.startsWith("postgres://")?{type:"postgres",url:t}:":memory:"===t?{type:"memory"}:{type:"sqlite",path:t}}export async function createConnection(n){let i=n.identity??t(),a=function(t){switch(t.type){case"http":case"postgres":return t.url;case"sqlite":return t.path;case"memory":return":memory:"}}(n);if("http"===n.type)return{provider:new o({identity:i,serverID:n.serverID,url:n.url}),dispose:async()=>{},type:"http",address:a};let u=new e({adapter:"postgres"===n.type?new p({url:n.url}):new r({database:"sqlite"===n.type?n.path:":memory:"})}),m=new s({db:u,identity:i,plugins:[]});return await m.ready,{provider:m,dispose:async()=>{await m.dispose(),await u.close()},type:n.type,address:a}}
|
package/lib/config.d.ts
CHANGED
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createConnection as t,parseDatabase as n}from"./client.js";import{prompts as o}from"./prompts/index.js";import{createClusterTools as e}from"./tools/cluster.js";import{createConnectionTools as i}from"./tools/connection.js";import{createGraphTools as r}from"./tools/graph.js";export async function createConfig(l={}){let s=null!=l.connect?{type:"http",url:l.connect,identity:l.identity}:null!=l.database?{...n(l.database),identity:l.identity}:null,a={current:null!=s?await t(s):null},c=i(a,l.identity),m=e(a),u=r(a);return{name:"kubun",version:"0.1.0",prompts:o,tools:{...c,...m,...u}}}
|
package/lib/container.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GraphsProvider } from '@kubun/protocol';
|
|
2
2
|
import type { ClientConnection } from './client.js';
|
|
3
3
|
export type ClientContainer = {
|
|
4
4
|
current: ClientConnection | null;
|
|
5
5
|
};
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getProvider(container: ClientContainer): GraphsProvider | null;
|
|
7
7
|
export declare function notConnectedError(): {
|
|
8
8
|
isError: true;
|
|
9
9
|
content: {
|
package/lib/container.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function getProvider(t){return t.current?.provider??null}export function notConnectedError(){return{isError:!0,content:[{type:"text",text:"No database connected. Use the connect tool first."}]}}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { type ClientConnection, type ClientParams,
|
|
1
|
+
export { type ClientConnection, type ClientParams, createConnection, parseDatabase, } from './client.js';
|
|
2
2
|
export { createConfig, type MCPConfig } from './config.js';
|
|
3
3
|
export type { ClientContainer } from './container.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{createConnection,parseDatabase}from"./client.js";export{createConfig}from"./config.js";
|
package/lib/run.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{parseArgs as
|
|
2
|
+
import{parseArgs as t}from"node:util";import{serveProcess as e}from"@mokei/context-server";import{createConfig as o}from"./config.js";let n=t({options:{connect:{type:"string"},db:{type:"string"}}});e(await o({connect:n.values.connect,database:n.values.db}));
|
package/lib/tools/cluster.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ClusterBuilder as e,clusterModel as t}from"@kubun/protocol";import{createTool as r}from"@mokei/context-server";import{
|
|
1
|
+
import{ClusterBuilder as e,clusterModel as t}from"@kubun/protocol";import{createTool as r}from"@mokei/context-server";import{getProvider as s,notConnectedError as o}from"../container.js";export function createClusterTools(n){return{create_cluster:r("Create a new cluster from model definitions",{type:"object",properties:{models:{type:"array",items:{type:"object"}}},required:["models"],additionalProperties:!1},async t=>{let r=new e;return r.addAll(t.arguments.models),{content:[{type:"text",text:"Cluster created"}],structuredContent:{cluster:r.build()}}}),deploy_clusters:r("Deploy clusters to the Kubun backend",{type:"object",properties:{clusters:{type:"array",items:t},id:{type:"string"},name:{type:"string"}},required:["clusters"],additionalProperties:!1},async e=>{let t=s(n);if(null==t)return o();let r=await t.deployGraph({clusters:e.arguments.clusters,id:e.arguments.id,name:e.arguments.name});return{content:[{type:"text",text:`Clusters deployed to graph "${r.id}"`}],structuredContent:{id:r.id,record:r.record,aliases:r.aliases}}})}}
|
package/lib/tools/connection.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createTool as t}from"@mokei/context-server";import{
|
|
1
|
+
import{createTool as t}from"@mokei/context-server";import{createConnection as e,parseDatabase as n}from"../client.js";export function createConnectionTools(r,o){let c=t("Connect to a Kubun database. Accepts a SQLite file path, postgres:// URL, http(s):// URL, or :memory: for in-memory.",{type:"object",properties:{database:{type:"string",description:"SQLite file path, postgres:// URL, http(s):// URL, or :memory:"}},required:["database"],additionalProperties:!1},async t=>{null!=r.current&&await r.current.dispose();try{let c=n(t.arguments.database),a=await e({...c,identity:o});return r.current=a,{content:[{type:"text",text:`Connected to ${a.type} database: ${a.address}`}],structuredContent:{type:a.type,address:a.address}}}catch(t){return r.current=null,{isError:!0,content:[{type:"text",text:`Failed to connect: ${t instanceof Error?t.message:String(t)}`}]}}});return{connect:c,disconnect:t("Disconnect from the current Kubun database",{type:"object"},async()=>(null!=r.current&&(await r.current.dispose(),r.current=null),{content:[{type:"text",text:"Disconnected"}]})),connection_info:t("Get information about the current database connection",{type:"object"},async()=>null==r.current?{content:[{type:"text",text:"Not connected"}],structuredContent:{connected:!1}}:{content:[{type:"text",text:`Connected to ${r.current.type} database: ${r.current.address}`}],structuredContent:{connected:!0,type:r.current.type,address:r.current.address}})}}
|
package/lib/tools/graph.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSchema as e}from"@kubun/graphql";import{createTool as t}from"@mokei/context-server";import{printSchema as r}from"graphql";import{
|
|
1
|
+
import{createSchema as e}from"@kubun/graphql";import{createTool as t}from"@mokei/context-server";import{printSchema as r}from"graphql";import{getProvider as n,notConnectedError as i}from"../container.js";export function createGraphTools(a){let o=t("List all available graphs",{type:"object"},async()=>{let e=n(a);if(null==e)return i();let t=await e.listGraphs(),r=t.graphs.map(e=>`${e.name} (${e.id})`).join(", ");return{content:[{type:"text",text:""===r?"No graphs available":`Available graphs: ${r}`}],structuredContent:{graphs:t.graphs}}}),s=t("Get information about a specific graph",{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1},async e=>{let t=n(a);if(null==t)return i();try{var r;let n,i=(n=(r=await t.loadGraph({id:e.arguments.id})).aliases??{},Object.entries(r.record).reduce((e,[t,r])=>(e[n[t]??r.name]={id:t,behavior:r.behavior,interfaces:r.interfaces,fields:Object.keys(r.schema.properties)},e),{}));return{content:[{type:"text",text:JSON.stringify(i)}],structuredContent:i}}catch(e){return{isError:!0,content:[{type:"text",text:`Failed to get GraphQL schema: ${e instanceof Error?e.message:String(e)}`}]}}}),u=t("Get the GraphQL schema for the given graph ID. Supports selective generation to reduce schema size for LLM context.",{type:"object",properties:{id:{type:"string",description:"The graph ID"},onlyModels:{type:"array",items:{type:"string"},description:"Optional array of model IDs or aliases to include in schema. If not provided, all models are included."},includeInterfaceDependencies:{type:"boolean",description:"Whether to include interface dependencies (default: true)"},includeRelationDependencies:{type:"boolean",description:"Whether to include relation dependencies (default: true)"},includeMutations:{type:"boolean",description:"Whether to include mutations in the schema (default: true)"},includeSubscriptions:{type:"boolean",description:"Whether to include subscriptions in the schema (default: true)"}},required:["id"],additionalProperties:!1},async t=>{let o=n(a);if(null==o)return i();try{let n=await o.loadGraph({id:t.arguments.id}),i=e({record:n.record,aliases:n.aliases,onlyModels:t.arguments.onlyModels,includeInterfaceDependencies:t.arguments.includeInterfaceDependencies,includeRelationDependencies:t.arguments.includeRelationDependencies,includeMutations:t.arguments.includeMutations,includeSubscriptions:t.arguments.includeSubscriptions});return{content:[{type:"text",text:r(i)}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Failed to get GraphQL schema: ${e instanceof Error?e.message:String(e)}`}]}}});return{graph_list:o,graph_info:s,graph_schema:u,graph_query:t("Execute a GraphQL query on the given graph ID",{type:"object",properties:{id:{type:"string"},query:{type:"string"},variables:{type:"object"}},required:["id","query"],additionalProperties:!1},async e=>{let t=n(a);if(null==t)return i();try{let r=await t.queryGraph({id:e.arguments.id,text:e.arguments.query,variables:e.arguments.variables??{}});if(null!=r.errors&&r.errors.length>0)return{isError:!0,content:[{type:"text",text:r.errors.map(e=>e.toString()).join(", ")}],structuredContent:{errors:r.errors}};return{content:[{type:"text",text:JSON.stringify(r.data)}],structuredContent:{data:r.data}}}catch(e){return{isError:!0,content:[{type:"text",text:`Failed to execute GraphQL query: ${e instanceof Error?e.message:String(e)}`}]}}}),graph_mutate:t("Execute a GraphQL mutation on the given graph ID",{type:"object",properties:{id:{type:"string"},query:{type:"string"},variables:{type:"object"}},required:["id","query"],additionalProperties:!1},async e=>{let t=n(a);if(null==t)return i();try{let r=await t.mutateGraph({id:e.arguments.id,text:e.arguments.query,variables:e.arguments.variables??{}});if(null!=r.errors&&r.errors.length>0)return{isError:!0,content:[{type:"text",text:r.errors.map(e=>e.toString()).join(", ")}],structuredContent:{errors:r.errors}};return{content:[{type:"text",text:JSON.stringify(r.data)}],structuredContent:{data:r.data}}}catch(e){return{isError:!0,content:[{type:"text",text:`Failed to execute GraphQL mutation: ${e instanceof Error?e.message:String(e)}`}]}}})}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -18,29 +18,28 @@
|
|
|
18
18
|
],
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@enkaku/token": "0.14.
|
|
21
|
+
"@enkaku/token": "0.14.1",
|
|
22
22
|
"@mokei/context-server": "^0.6.0",
|
|
23
|
-
"graphql": "^16.13.
|
|
24
|
-
"@kubun/db": "^0.
|
|
25
|
-
"@kubun/db-
|
|
26
|
-
"@kubun/graphql": "^0.
|
|
27
|
-
"@kubun/
|
|
28
|
-
"@kubun/
|
|
29
|
-
"@kubun/
|
|
30
|
-
"@kubun/
|
|
23
|
+
"graphql": "^16.13.2",
|
|
24
|
+
"@kubun/db-node-sqlite": "^0.8.0",
|
|
25
|
+
"@kubun/db-postgres": "^0.8.0",
|
|
26
|
+
"@kubun/graphql": "^0.8.0",
|
|
27
|
+
"@kubun/engine": "^0.8.0",
|
|
28
|
+
"@kubun/http-client": "^0.8.0",
|
|
29
|
+
"@kubun/db": "^0.8.0",
|
|
30
|
+
"@kubun/protocol": "^0.8.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@enkaku/transport": "0.14.0",
|
|
34
34
|
"@mokei/context-client": "^0.6.0",
|
|
35
|
-
"@mokei/context-protocol": "^0.6.0"
|
|
36
|
-
"@kubun/client": "^0.7.0"
|
|
35
|
+
"@mokei/context-protocol": "^0.6.0"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|
|
39
38
|
"build:clean": "del lib",
|
|
40
39
|
"build:js": "swc src -d ./lib --config-file ../../swc.json --strip-leading-paths",
|
|
41
40
|
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
42
41
|
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
43
|
-
"test:types": "tsc --noEmit",
|
|
42
|
+
"test:types": "tsc --noEmit -p tsconfig.test.json",
|
|
44
43
|
"test:unit": "vitest run",
|
|
45
44
|
"test": "pnpm run test:types && pnpm run test:unit"
|
|
46
45
|
}
|