@kasarlabs/ask-starknet-core 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/build/index.d.ts +2 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/build/interfaces/index.d.ts +15 -0
- package/build/interfaces/index.js +2 -0
- package/build/interfaces/index.js.map +1 -0
- package/build/utils/index.d.ts +4 -0
- package/build/utils/index.js +54 -0
- package/build/utils/index.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kasar Labs
|
|
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/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Account, RpcProvider } from 'starknet';
|
|
3
|
+
export interface mcpTool {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema?: z.ZodObject<any>;
|
|
7
|
+
execute: (params: any) => Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export interface onchainRead {
|
|
10
|
+
provider: RpcProvider;
|
|
11
|
+
}
|
|
12
|
+
export interface onchainWrite {
|
|
13
|
+
provider: RpcProvider;
|
|
14
|
+
account: Account;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { mcpTool, onchainRead, onchainWrite } from '../interfaces/index.js';
|
|
2
|
+
export declare const registerToolsWithServer: (server: any, tools: mcpTool[]) => Promise<void>;
|
|
3
|
+
export declare const getOnchainRead: () => onchainRead;
|
|
4
|
+
export declare const getOnchainWrite: () => onchainWrite;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Account, RpcProvider } from 'starknet';
|
|
2
|
+
export const registerToolsWithServer = async (server, tools) => {
|
|
3
|
+
for (const tool of tools) {
|
|
4
|
+
if (!tool.schema) {
|
|
5
|
+
server.tool(tool.name, tool.description, async () => {
|
|
6
|
+
const result = await tool.execute({});
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{
|
|
10
|
+
type: 'text',
|
|
11
|
+
text: JSON.stringify(result),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
server.tool(tool.name, tool.description, tool.schema.shape, async (params, extra) => {
|
|
19
|
+
const result = await tool.execute(params);
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: JSON.stringify(result),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const getOnchainRead = () => {
|
|
33
|
+
if (!process.env.STARKNET_RPC_URL) {
|
|
34
|
+
throw new Error('Missing required environment variables: STARKNET_RPC_URL');
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
provider: new RpcProvider({ nodeUrl: process.env.STARKNET_RPC_URL }),
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export const getOnchainWrite = () => {
|
|
41
|
+
const rpcUrl = process.env.STARKNET_RPC_URL;
|
|
42
|
+
const privateKey = process.env.STARKNET_PRIVATE_KEY;
|
|
43
|
+
const accountAddress = process.env.STARKNET_ACCOUNT_ADDRESS;
|
|
44
|
+
if (!rpcUrl || !privateKey || !accountAddress) {
|
|
45
|
+
throw new Error('Missing required environment variables: STARKNET_RPC_URL, STARKNET_PRIVATE_KEY, STARKNET_ACCOUNT_ADDRESS');
|
|
46
|
+
}
|
|
47
|
+
const provider = new RpcProvider({ nodeUrl: rpcUrl });
|
|
48
|
+
const account = new Account(provider, accountAddress, privateKey);
|
|
49
|
+
return {
|
|
50
|
+
provider,
|
|
51
|
+
account,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AA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C,gBAAgB,EAAE,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAiB,EAAE;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IACpD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IAE5D,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,IAAI,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IAElE,OAAO;QACL,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kasarlabs/ask-starknet-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core utilities and shared functionality for the Ask Starknet MCP ecosystem",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"clean": "rm -rf build",
|
|
11
|
+
"clean:all": "rm -rf build node_modules",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"test": "jest"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"build"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"starknet",
|
|
20
|
+
"mcp",
|
|
21
|
+
"core",
|
|
22
|
+
"utilities"
|
|
23
|
+
],
|
|
24
|
+
"author": "kasarlabs",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"starknet": "^7.6.4",
|
|
31
|
+
"winston": "^3.17.0",
|
|
32
|
+
"zod": "^3.24.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/jest": "^29.0.0",
|
|
36
|
+
"@types/node": "^22.13.10",
|
|
37
|
+
"jest": "^29.0.0",
|
|
38
|
+
"typescript": "^5.8.2"
|
|
39
|
+
},
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"import": "./build/index.js",
|
|
43
|
+
"types": "./build/index.d.ts"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "2239ec60f8e369abd318807cecd22fe97c0ab917"
|
|
47
|
+
}
|