@kubun/mcp 0.5.1 → 0.5.2
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 +8 -1
- package/lib/client.js +1 -1
- package/lib/config.js +1 -1
- package/lib/container.d.ts +13 -0
- package/lib/container.js +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/tools/cluster.d.ts +2 -2
- package/lib/tools/cluster.js +1 -1
- package/lib/tools/connection.d.ts +6 -0
- package/lib/tools/connection.js +1 -0
- package/lib/tools/graph.d.ts +2 -2
- package/lib/tools/graph.js +1 -1
- package/lib/tools/index.d.ts +1 -0
- package/lib/tools/index.js +1 -1
- package/package.json +6 -6
package/lib/client.d.ts
CHANGED
|
@@ -16,4 +16,11 @@ export type ClientConfig = {
|
|
|
16
16
|
export type ClientParams = ClientConfig & {
|
|
17
17
|
identity?: SigningIdentity;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type ClientConnection = {
|
|
20
|
+
client: KubunClient;
|
|
21
|
+
dispose: () => Promise<void>;
|
|
22
|
+
type: ClientConfig['type'];
|
|
23
|
+
address: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function parseDatabase(database: string): ClientConfig;
|
|
26
|
+
export declare function createClient(params: ClientParams): ClientConnection;
|
package/lib/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomIdentity 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 s}from"@kubun/db-postgres";import{HTTPClient as p}from"@kubun/http-client";import{KubunServer as n}from"@kubun/server";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 function createClient(o){let i=o.identity??t(),u=function(t){switch(t.type){case"http":case"postgres":return t.url;case"sqlite":return t.path;case"memory":return":memory:"}}(o);if("http"===o.type)return{client:new p({identity:i,serverID:o.serverID,url:o.url}),dispose:async()=>{},type:"http",address:u};let a=new e({adapter:"postgres"===o.type?new s({url:o.url}):new r({database:"sqlite"===o.type?o.path:":memory:"})});return{client:new n({db:a,identity:i}).createClient({identity:i}),dispose:async()=>{await a.close()},type:o.type,address:u}}
|
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createClient as t}from"./client.js";import{prompts as
|
|
1
|
+
import{createClient 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 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,m={current:null!=s?t(s):null},u=i(m,l.identity),c=e(m),p=r(m);return{name:"kubun",version:"0.1.0",prompts:o,tools:{...u,...c,...p}}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { KubunClient } from '@kubun/client';
|
|
2
|
+
import type { ClientConnection } from './client.js';
|
|
3
|
+
export type ClientContainer = {
|
|
4
|
+
current: ClientConnection | null;
|
|
5
|
+
};
|
|
6
|
+
export declare function getClient(container: ClientContainer): KubunClient | null;
|
|
7
|
+
export declare function notConnectedError(): {
|
|
8
|
+
isError: true;
|
|
9
|
+
content: {
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
package/lib/container.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getClient(t){return t.current?.client??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,2 +1,3 @@
|
|
|
1
|
-
export { type ClientParams, createClient } from './client.js';
|
|
1
|
+
export { type ClientConnection, type ClientParams, createClient, parseDatabase } from './client.js';
|
|
2
2
|
export { createConfig, type MCPConfig } from './config.js';
|
|
3
|
+
export type { ClientContainer } from './container.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{createClient}from"./client.js";export{createConfig}from"./config.js";
|
|
1
|
+
export{createClient,parseDatabase}from"./client.js";export{createConfig}from"./config.js";
|
package/lib/tools/cluster.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { KubunClient } from '@kubun/client';
|
|
2
1
|
import { createTool } from '@mokei/context-server';
|
|
2
|
+
import { type ClientContainer } from '../container.js';
|
|
3
3
|
type ToolDefinition = ReturnType<typeof createTool>;
|
|
4
|
-
export declare function createClusterTools(
|
|
4
|
+
export declare function createClusterTools(container: ClientContainer): Record<string, ToolDefinition>;
|
|
5
5
|
export {};
|
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";export function createClusterTools(
|
|
1
|
+
import{ClusterBuilder as e,clusterModel as t}from"@kubun/protocol";import{createTool as r}from"@mokei/context-server";import{getClient 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}}})}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SigningIdentity } from '@enkaku/token';
|
|
2
|
+
import { createTool } from '@mokei/context-server';
|
|
3
|
+
import type { ClientContainer } from '../container.js';
|
|
4
|
+
type ToolDefinition = ReturnType<typeof createTool>;
|
|
5
|
+
export declare function createConnectionTools(container: ClientContainer, identity?: SigningIdentity): Record<string, ToolDefinition>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createTool as t}from"@mokei/context-server";import{createClient 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),s=e({...c,identity:o});return r.current=s,{content:[{type:"text",text:`Connected to ${s.type} database: ${s.address}`}],structuredContent:{type:s.type,address:s.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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { KubunClient } from '@kubun/client';
|
|
2
1
|
import { createTool } from '@mokei/context-server';
|
|
2
|
+
import { type ClientContainer } from '../container.js';
|
|
3
3
|
type ToolDefinition = ReturnType<typeof createTool>;
|
|
4
|
-
export declare function createGraphTools(
|
|
4
|
+
export declare function createGraphTools(container: ClientContainer): Record<string, ToolDefinition>;
|
|
5
5
|
export {};
|
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";export function createGraphTools(
|
|
1
|
+
import{createSchema as e}from"@kubun/graphql";import{createTool as t}from"@mokei/context-server";import{printSchema as r}from"graphql";import{getClient 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/lib/tools/index.d.ts
CHANGED
package/lib/tools/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{createClusterTools}from"./cluster.js";export{createGraphTools}from"./graph.js";
|
|
1
|
+
export{createClusterTools}from"./cluster.js";export{createConnectionTools}from"./connection.js";export{createGraphTools}from"./graph.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"@enkaku/token": "0.13.0",
|
|
22
22
|
"@mokei/context-server": "^0.5.0",
|
|
23
23
|
"graphql": "^16.12.0",
|
|
24
|
-
"@kubun/
|
|
25
|
-
"@kubun/db-
|
|
26
|
-
"@kubun/server": "^0.5.0",
|
|
24
|
+
"@kubun/graphql": "^0.5.0",
|
|
25
|
+
"@kubun/db-node-sqlite": "^0.5.0",
|
|
27
26
|
"@kubun/protocol": "^0.5.3",
|
|
27
|
+
"@kubun/db-postgres": "^0.5.0",
|
|
28
|
+
"@kubun/db": "^0.5.1",
|
|
28
29
|
"@kubun/http-client": "^0.5.0",
|
|
29
|
-
"@kubun/
|
|
30
|
-
"@kubun/db-node-sqlite": "^0.5.0"
|
|
30
|
+
"@kubun/server": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@enkaku/transport": "0.13.1",
|