@openzeppelin/contracts-mcp 0.0.5
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 +661 -0
- package/NOTICE +8 -0
- package/README.md +100 -0
- package/dist/cairo/schemas.d.ts +203 -0
- package/dist/cairo/schemas.d.ts.map +1 -0
- package/dist/cairo/schemas.js +132 -0
- package/dist/cairo/schemas.js.map +1 -0
- package/dist/cairo/tools/account.d.ts +3 -0
- package/dist/cairo/tools/account.d.ts.map +1 -0
- package/dist/cairo/tools/account.js +30 -0
- package/dist/cairo/tools/account.js.map +1 -0
- package/dist/cairo/tools/custom.d.ts +3 -0
- package/dist/cairo/tools/custom.d.ts.map +1 -0
- package/dist/cairo/tools/custom.js +27 -0
- package/dist/cairo/tools/custom.js.map +1 -0
- package/dist/cairo/tools/erc1155.d.ts +3 -0
- package/dist/cairo/tools/erc1155.d.ts.map +1 -0
- package/dist/cairo/tools/erc1155.js +32 -0
- package/dist/cairo/tools/erc1155.js.map +1 -0
- package/dist/cairo/tools/erc20.d.ts +3 -0
- package/dist/cairo/tools/erc20.d.ts.map +1 -0
- package/dist/cairo/tools/erc20.js +34 -0
- package/dist/cairo/tools/erc20.js.map +1 -0
- package/dist/cairo/tools/erc721.d.ts +3 -0
- package/dist/cairo/tools/erc721.d.ts.map +1 -0
- package/dist/cairo/tools/erc721.js +36 -0
- package/dist/cairo/tools/erc721.js.map +1 -0
- package/dist/cairo/tools/governor.d.ts +3 -0
- package/dist/cairo/tools/governor.d.ts.map +1 -0
- package/dist/cairo/tools/governor.js +38 -0
- package/dist/cairo/tools/governor.js.map +1 -0
- package/dist/cairo/tools/multisig.d.ts +3 -0
- package/dist/cairo/tools/multisig.d.ts.map +1 -0
- package/dist/cairo/tools/multisig.js +26 -0
- package/dist/cairo/tools/multisig.js.map +1 -0
- package/dist/cairo/tools/vesting.d.ts +3 -0
- package/dist/cairo/tools/vesting.d.ts.map +1 -0
- package/dist/cairo/tools/vesting.js +28 -0
- package/dist/cairo/tools/vesting.js.map +1 -0
- package/dist/cairo/tools.d.ts +3 -0
- package/dist/cairo/tools.d.ts.map +1 -0
- package/dist/cairo/tools.js +29 -0
- package/dist/cairo/tools.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +28 -0
- package/dist/server.js.map +1 -0
- package/dist/solidity/schemas.d.ts +203 -0
- package/dist/solidity/schemas.d.ts.map +1 -0
- package/dist/solidity/schemas.js +160 -0
- package/dist/solidity/schemas.js.map +1 -0
- package/dist/solidity/tools/account.d.ts +3 -0
- package/dist/solidity/tools/account.d.ts.map +1 -0
- package/dist/solidity/tools/account.js +30 -0
- package/dist/solidity/tools/account.js.map +1 -0
- package/dist/solidity/tools/custom.d.ts +3 -0
- package/dist/solidity/tools/custom.d.ts.map +1 -0
- package/dist/solidity/tools/custom.js +27 -0
- package/dist/solidity/tools/custom.js.map +1 -0
- package/dist/solidity/tools/erc1155.d.ts +3 -0
- package/dist/solidity/tools/erc1155.d.ts.map +1 -0
- package/dist/solidity/tools/erc1155.js +32 -0
- package/dist/solidity/tools/erc1155.js.map +1 -0
- package/dist/solidity/tools/erc20.d.ts +3 -0
- package/dist/solidity/tools/erc20.d.ts.map +1 -0
- package/dist/solidity/tools/erc20.js +37 -0
- package/dist/solidity/tools/erc20.js.map +1 -0
- package/dist/solidity/tools/erc721.d.ts +3 -0
- package/dist/solidity/tools/erc721.d.ts.map +1 -0
- package/dist/solidity/tools/erc721.js +35 -0
- package/dist/solidity/tools/erc721.js.map +1 -0
- package/dist/solidity/tools/governor.d.ts +3 -0
- package/dist/solidity/tools/governor.d.ts.map +1 -0
- package/dist/solidity/tools/governor.js +38 -0
- package/dist/solidity/tools/governor.js.map +1 -0
- package/dist/solidity/tools/rwa.d.ts +3 -0
- package/dist/solidity/tools/rwa.d.ts.map +1 -0
- package/dist/solidity/tools/rwa.js +38 -0
- package/dist/solidity/tools/rwa.js.map +1 -0
- package/dist/solidity/tools/stablecoin.d.ts +3 -0
- package/dist/solidity/tools/stablecoin.d.ts.map +1 -0
- package/dist/solidity/tools/stablecoin.js +38 -0
- package/dist/solidity/tools/stablecoin.js.map +1 -0
- package/dist/solidity/tools.d.ts +3 -0
- package/dist/solidity/tools.d.ts.map +1 -0
- package/dist/solidity/tools.js +29 -0
- package/dist/solidity/tools.js.map +1 -0
- package/dist/stellar/schemas.d.ts +79 -0
- package/dist/stellar/schemas.d.ts.map +1 -0
- package/dist/stellar/schemas.js +56 -0
- package/dist/stellar/schemas.js.map +1 -0
- package/dist/stellar/tools/fungible.d.ts +3 -0
- package/dist/stellar/tools/fungible.d.ts.map +1 -0
- package/dist/stellar/tools/fungible.js +31 -0
- package/dist/stellar/tools/fungible.js.map +1 -0
- package/dist/stellar/tools/non-fungible.d.ts +3 -0
- package/dist/stellar/tools/non-fungible.d.ts.map +1 -0
- package/dist/stellar/tools/non-fungible.js +32 -0
- package/dist/stellar/tools/non-fungible.js.map +1 -0
- package/dist/stellar/tools/stablecoin.d.ts +3 -0
- package/dist/stellar/tools/stablecoin.d.ts.map +1 -0
- package/dist/stellar/tools/stablecoin.js +32 -0
- package/dist/stellar/tools/stablecoin.js.map +1 -0
- package/dist/stellar/tools.d.ts +3 -0
- package/dist/stellar/tools.d.ts.map +1 -0
- package/dist/stellar/tools.js +19 -0
- package/dist/stellar/tools.js.map +1 -0
- package/dist/stylus/schemas.d.ts +60 -0
- package/dist/stylus/schemas.d.ts.map +1 -0
- package/dist/stylus/schemas.js +44 -0
- package/dist/stylus/schemas.js.map +1 -0
- package/dist/stylus/tools/erc1155.d.ts +3 -0
- package/dist/stylus/tools/erc1155.d.ts.map +1 -0
- package/dist/stylus/tools/erc1155.js +26 -0
- package/dist/stylus/tools/erc1155.js.map +1 -0
- package/dist/stylus/tools/erc20.d.ts +3 -0
- package/dist/stylus/tools/erc20.d.ts.map +1 -0
- package/dist/stylus/tools/erc20.js +27 -0
- package/dist/stylus/tools/erc20.js.map +1 -0
- package/dist/stylus/tools/erc721.d.ts +3 -0
- package/dist/stylus/tools/erc721.d.ts.map +1 -0
- package/dist/stylus/tools/erc721.js +26 -0
- package/dist/stylus/tools/erc721.js.map +1 -0
- package/dist/stylus/tools.d.ts +3 -0
- package/dist/stylus/tools.d.ts.map +1 -0
- package/dist/stylus/tools.js +19 -0
- package/dist/stylus/tools.js.map +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +61 -0
- package/dist/utils.js.map +1 -0
- package/package.json +40 -0
- package/src/cairo/schemas.ts +153 -0
- package/src/cairo/tools/account.ts +34 -0
- package/src/cairo/tools/custom.ts +31 -0
- package/src/cairo/tools/erc1155.ts +36 -0
- package/src/cairo/tools/erc20.ts +51 -0
- package/src/cairo/tools/erc721.ts +55 -0
- package/src/cairo/tools/governor.ts +59 -0
- package/src/cairo/tools/multisig.ts +30 -0
- package/src/cairo/tools/vesting.ts +32 -0
- package/src/cairo/tools.ts +34 -0
- package/src/index.ts +11 -0
- package/src/server.ts +30 -0
- package/src/solidity/schemas.ts +180 -0
- package/src/solidity/tools/account.ts +43 -0
- package/src/solidity/tools/custom.ts +31 -0
- package/src/solidity/tools/erc1155.ts +36 -0
- package/src/solidity/tools/erc20.ts +57 -0
- package/src/solidity/tools/erc721.ts +53 -0
- package/src/solidity/tools/governor.ts +59 -0
- package/src/solidity/tools/rwa.ts +59 -0
- package/src/solidity/tools/stablecoin.ts +59 -0
- package/src/solidity/tools.ts +34 -0
- package/src/stellar/schemas.ts +67 -0
- package/src/stellar/tools/fungible.ts +35 -0
- package/src/stellar/tools/non-fungible.ts +36 -0
- package/src/stellar/tools/stablecoin.ts +36 -0
- package/src/stellar/tools.ts +24 -0
- package/src/stylus/schemas.ts +54 -0
- package/src/stylus/tools/erc1155.ts +30 -0
- package/src/stylus/tools/erc20.ts +31 -0
- package/src/stylus/tools/erc721.ts +30 -0
- package/src/stylus/tools.ts +24 -0
- package/src/utils.ts +59 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { FungibleOptions } from '@openzeppelin/wizard-stellar';
|
|
3
|
+
import { fungible } from '@openzeppelin/wizard-stellar';
|
|
4
|
+
import { safePrintRustCodeBlock, makeDetailedPrompt } from '../../utils';
|
|
5
|
+
import { fungibleSchema } from '../schemas';
|
|
6
|
+
import { stellarPrompts } from '@openzeppelin/wizard-common';
|
|
7
|
+
|
|
8
|
+
export function registerStellarFungible(server: McpServer): RegisteredTool {
|
|
9
|
+
return server.tool(
|
|
10
|
+
'stellar-fungible',
|
|
11
|
+
makeDetailedPrompt(stellarPrompts.Fungible),
|
|
12
|
+
fungibleSchema,
|
|
13
|
+
async ({ name, symbol, burnable, pausable, premint, mintable, upgradeable, access, info }) => {
|
|
14
|
+
const opts: FungibleOptions = {
|
|
15
|
+
name,
|
|
16
|
+
symbol,
|
|
17
|
+
burnable,
|
|
18
|
+
pausable,
|
|
19
|
+
premint,
|
|
20
|
+
mintable,
|
|
21
|
+
upgradeable,
|
|
22
|
+
access,
|
|
23
|
+
info,
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: safePrintRustCodeBlock(() => fungible.print(opts)),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NonFungibleOptions } from '@openzeppelin/wizard-stellar';
|
|
3
|
+
import { nonFungible } from '@openzeppelin/wizard-stellar';
|
|
4
|
+
import { safePrintRustCodeBlock, makeDetailedPrompt } from '../../utils';
|
|
5
|
+
import { nonFungibleSchema } from '../schemas';
|
|
6
|
+
import { stellarPrompts } from '@openzeppelin/wizard-common';
|
|
7
|
+
|
|
8
|
+
export function registerStellarNonFungible(server: McpServer): RegisteredTool {
|
|
9
|
+
return server.tool(
|
|
10
|
+
'stellar-non-fungible',
|
|
11
|
+
makeDetailedPrompt(stellarPrompts.NonFungible),
|
|
12
|
+
nonFungibleSchema,
|
|
13
|
+
async ({ name, symbol, burnable, enumerable, consecutive, pausable, mintable, sequential, upgradeable, info }) => {
|
|
14
|
+
const opts: NonFungibleOptions = {
|
|
15
|
+
name,
|
|
16
|
+
symbol,
|
|
17
|
+
burnable,
|
|
18
|
+
enumerable,
|
|
19
|
+
consecutive,
|
|
20
|
+
pausable,
|
|
21
|
+
mintable,
|
|
22
|
+
sequential,
|
|
23
|
+
upgradeable,
|
|
24
|
+
info,
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: safePrintRustCodeBlock(() => nonFungible.print(opts)),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { StablecoinOptions } from '@openzeppelin/wizard-stellar';
|
|
3
|
+
import { stablecoin } from '@openzeppelin/wizard-stellar';
|
|
4
|
+
import { safePrintRustCodeBlock, makeDetailedPrompt } from '../../utils';
|
|
5
|
+
import { stablecoinSchema } from '../schemas';
|
|
6
|
+
import { stellarPrompts } from '@openzeppelin/wizard-common';
|
|
7
|
+
|
|
8
|
+
export function registerStellarStablecoin(server: McpServer): RegisteredTool {
|
|
9
|
+
return server.tool(
|
|
10
|
+
'stellar-stablecoin',
|
|
11
|
+
makeDetailedPrompt(stellarPrompts.Stablecoin),
|
|
12
|
+
stablecoinSchema,
|
|
13
|
+
async ({ name, symbol, burnable, pausable, premint, mintable, upgradeable, access, limitations, info }) => {
|
|
14
|
+
const opts: StablecoinOptions = {
|
|
15
|
+
name,
|
|
16
|
+
symbol,
|
|
17
|
+
burnable,
|
|
18
|
+
pausable,
|
|
19
|
+
premint,
|
|
20
|
+
mintable,
|
|
21
|
+
upgradeable,
|
|
22
|
+
access,
|
|
23
|
+
limitations,
|
|
24
|
+
info,
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: safePrintRustCodeBlock(() => stablecoin.print(opts)),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { registerStellarFungible } from './tools/fungible.js';
|
|
3
|
+
import { registerStellarStablecoin } from './tools/stablecoin.js';
|
|
4
|
+
import { registerStellarNonFungible } from './tools/non-fungible.js';
|
|
5
|
+
import type { KindedOptions } from '@openzeppelin/wizard-stellar';
|
|
6
|
+
import type { RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
|
|
8
|
+
type StellarToolRegisterFunctions = {
|
|
9
|
+
[kind in keyof KindedOptions]: (server: McpServer) => RegisteredTool;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function getRegisterFunctions(server: McpServer): StellarToolRegisterFunctions {
|
|
13
|
+
return {
|
|
14
|
+
Fungible: () => registerStellarFungible(server),
|
|
15
|
+
Stablecoin: () => registerStellarStablecoin(server),
|
|
16
|
+
NonFungible: () => registerStellarNonFungible(server),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function registerStellarTools(server: McpServer) {
|
|
21
|
+
Object.values(getRegisterFunctions(server)).forEach(registerTool => {
|
|
22
|
+
registerTool(server);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
commonDescriptions,
|
|
4
|
+
infoDescriptions,
|
|
5
|
+
stylusERC20Descriptions,
|
|
6
|
+
stylusERC721Descriptions,
|
|
7
|
+
stylusERC1155Descriptions,
|
|
8
|
+
} from '@openzeppelin/wizard-common';
|
|
9
|
+
import type { KindedOptions } from '@openzeppelin/wizard-stylus';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Static type assertions to ensure schemas satisfy the Wizard API types. Not called at runtime.
|
|
13
|
+
*/
|
|
14
|
+
function _typeAssertions() {
|
|
15
|
+
const _assertions: {
|
|
16
|
+
[K in keyof KindedOptions]: Omit<KindedOptions[K], 'kind'>;
|
|
17
|
+
} = {
|
|
18
|
+
ERC20: z.object(erc20Schema).parse({}),
|
|
19
|
+
ERC721: z.object(erc721Schema).parse({}),
|
|
20
|
+
ERC1155: z.object(erc1155Schema).parse({}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const commonSchema = {
|
|
25
|
+
info: z
|
|
26
|
+
.object({
|
|
27
|
+
securityContact: z.string().optional().describe(infoDescriptions.securityContact),
|
|
28
|
+
license: z.string().optional().describe(infoDescriptions.license),
|
|
29
|
+
})
|
|
30
|
+
.optional()
|
|
31
|
+
.describe(infoDescriptions.info),
|
|
32
|
+
} as const satisfies z.ZodRawShape;
|
|
33
|
+
|
|
34
|
+
export const erc20Schema = {
|
|
35
|
+
name: z.string().describe(commonDescriptions.name),
|
|
36
|
+
burnable: z.boolean().optional().describe(commonDescriptions.burnable),
|
|
37
|
+
permit: z.boolean().optional().describe(stylusERC20Descriptions.permit),
|
|
38
|
+
flashmint: z.boolean().optional().describe(stylusERC20Descriptions.flashmint),
|
|
39
|
+
...commonSchema,
|
|
40
|
+
} as const satisfies z.ZodRawShape;
|
|
41
|
+
|
|
42
|
+
export const erc721Schema = {
|
|
43
|
+
name: z.string().describe(commonDescriptions.name),
|
|
44
|
+
burnable: z.boolean().optional().describe(commonDescriptions.burnable),
|
|
45
|
+
enumerable: z.boolean().optional().describe(stylusERC721Descriptions.enumerable),
|
|
46
|
+
...commonSchema,
|
|
47
|
+
} as const satisfies z.ZodRawShape;
|
|
48
|
+
|
|
49
|
+
export const erc1155Schema = {
|
|
50
|
+
name: z.string().describe(commonDescriptions.name),
|
|
51
|
+
burnable: z.boolean().optional().describe(commonDescriptions.burnable),
|
|
52
|
+
supply: z.boolean().optional().describe(stylusERC1155Descriptions.supply),
|
|
53
|
+
...commonSchema,
|
|
54
|
+
} as const satisfies z.ZodRawShape;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ERC1155Options } from '@openzeppelin/wizard-stylus';
|
|
3
|
+
import { erc1155 } from '@openzeppelin/wizard-stylus';
|
|
4
|
+
import { safePrintRustCodeBlock, makeDetailedPrompt } from '../../utils';
|
|
5
|
+
import { erc1155Schema } from '../schemas';
|
|
6
|
+
import { stylusPrompts } from '@openzeppelin/wizard-common';
|
|
7
|
+
|
|
8
|
+
export function registerStylusERC1155(server: McpServer): RegisteredTool {
|
|
9
|
+
return server.tool(
|
|
10
|
+
'stylus-erc1155',
|
|
11
|
+
makeDetailedPrompt(stylusPrompts.ERC1155),
|
|
12
|
+
erc1155Schema,
|
|
13
|
+
async ({ name, burnable, supply, info }) => {
|
|
14
|
+
const opts: ERC1155Options = {
|
|
15
|
+
name,
|
|
16
|
+
burnable,
|
|
17
|
+
supply,
|
|
18
|
+
info,
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: safePrintRustCodeBlock(() => erc1155.print(opts)),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ERC20Options } from '@openzeppelin/wizard-stylus';
|
|
3
|
+
import { erc20 } from '@openzeppelin/wizard-stylus';
|
|
4
|
+
import { safePrintRustCodeBlock, makeDetailedPrompt } from '../../utils';
|
|
5
|
+
import { erc20Schema } from '../schemas';
|
|
6
|
+
import { stylusPrompts } from '@openzeppelin/wizard-common';
|
|
7
|
+
|
|
8
|
+
export function registerStylusERC20(server: McpServer): RegisteredTool {
|
|
9
|
+
return server.tool(
|
|
10
|
+
'stylus-erc20',
|
|
11
|
+
makeDetailedPrompt(stylusPrompts.ERC20),
|
|
12
|
+
erc20Schema,
|
|
13
|
+
async ({ name, burnable, permit, flashmint, info }) => {
|
|
14
|
+
const opts: ERC20Options = {
|
|
15
|
+
name,
|
|
16
|
+
burnable,
|
|
17
|
+
permit,
|
|
18
|
+
flashmint,
|
|
19
|
+
info,
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: safePrintRustCodeBlock(() => erc20.print(opts)),
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ERC721Options } from '@openzeppelin/wizard-stylus';
|
|
3
|
+
import { erc721 } from '@openzeppelin/wizard-stylus';
|
|
4
|
+
import { safePrintRustCodeBlock, makeDetailedPrompt } from '../../utils';
|
|
5
|
+
import { erc721Schema } from '../schemas';
|
|
6
|
+
import { stylusPrompts } from '@openzeppelin/wizard-common';
|
|
7
|
+
|
|
8
|
+
export function registerStylusERC721(server: McpServer): RegisteredTool {
|
|
9
|
+
return server.tool(
|
|
10
|
+
'stylus-erc721',
|
|
11
|
+
makeDetailedPrompt(stylusPrompts.ERC721),
|
|
12
|
+
erc721Schema,
|
|
13
|
+
async ({ name, burnable, enumerable, info }) => {
|
|
14
|
+
const opts: ERC721Options = {
|
|
15
|
+
name,
|
|
16
|
+
burnable,
|
|
17
|
+
enumerable,
|
|
18
|
+
info,
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: safePrintRustCodeBlock(() => erc721.print(opts)),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { registerStylusERC20 } from './tools/erc20';
|
|
3
|
+
import { registerStylusERC721 } from './tools/erc721';
|
|
4
|
+
import { registerStylusERC1155 } from './tools/erc1155';
|
|
5
|
+
import type { KindedOptions } from '@openzeppelin/wizard-stylus';
|
|
6
|
+
import type { RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
|
|
8
|
+
type StylusToolRegisterFunctions = {
|
|
9
|
+
[kind in keyof KindedOptions]: (server: McpServer) => RegisteredTool;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function getRegisterFunctions(server: McpServer): StylusToolRegisterFunctions {
|
|
13
|
+
return {
|
|
14
|
+
ERC20: () => registerStylusERC20(server),
|
|
15
|
+
ERC721: () => registerStylusERC721(server),
|
|
16
|
+
ERC1155: () => registerStylusERC1155(server),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function registerStylusTools(server: McpServer) {
|
|
21
|
+
Object.values(getRegisterFunctions(server)).forEach(registerTool => {
|
|
22
|
+
registerTool(server);
|
|
23
|
+
});
|
|
24
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { OptionsError as OptionsErrorSolidity } from '@openzeppelin/wizard';
|
|
2
|
+
import { OptionsError as OptionsErrorCairo } from '@openzeppelin/wizard-cairo';
|
|
3
|
+
import { OptionsError as OptionsErrorStylus } from '@openzeppelin/wizard-stylus';
|
|
4
|
+
import { OptionsError as OptionsErrorStellar } from '@openzeppelin/wizard-stellar';
|
|
5
|
+
|
|
6
|
+
function safePrintCodeBlock(printFn: () => string, syntaxHighlightingLanguage: string): string {
|
|
7
|
+
try {
|
|
8
|
+
return `\
|
|
9
|
+
\`\`\`${syntaxHighlightingLanguage}
|
|
10
|
+
${printFn()}
|
|
11
|
+
\`\`\`
|
|
12
|
+
`;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (
|
|
15
|
+
e instanceof OptionsErrorSolidity ||
|
|
16
|
+
e instanceof OptionsErrorCairo ||
|
|
17
|
+
e instanceof OptionsErrorStylus ||
|
|
18
|
+
e instanceof OptionsErrorStellar
|
|
19
|
+
) {
|
|
20
|
+
return `${e.message}\n\n${JSON.stringify(e.messages, null, 2)}`;
|
|
21
|
+
} else {
|
|
22
|
+
return `Unexpected error: ${e}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Prints the contract source code, wrapped in a Markdown code block with syntax highlighting as `solidity`.
|
|
29
|
+
* Or prints the error message if an error occurs.
|
|
30
|
+
*/
|
|
31
|
+
export function safePrintSolidityCodeBlock(printFn: () => string): string {
|
|
32
|
+
return safePrintCodeBlock(printFn, 'solidity');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Prints the contract source code, wrapped in a Markdown code block with syntax highlighting as `cairo`.
|
|
37
|
+
* Or prints the error message if an error occurs.
|
|
38
|
+
*/
|
|
39
|
+
export function safePrintCairoCodeBlock(printFn: () => string): string {
|
|
40
|
+
return safePrintCodeBlock(printFn, 'cairo');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Prints the contract source code, wrapped in a Markdown code block with syntax highlighting as `rust`.
|
|
45
|
+
* Or prints the error message if an error occurs.
|
|
46
|
+
*/
|
|
47
|
+
export function safePrintRustCodeBlock(printFn: () => string): string {
|
|
48
|
+
return safePrintCodeBlock(printFn, 'rust');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Adds a description to the prompt that explains the return format of the tool.
|
|
53
|
+
*/
|
|
54
|
+
export function makeDetailedPrompt(origPrompt: string): string {
|
|
55
|
+
return `\
|
|
56
|
+
${origPrompt}
|
|
57
|
+
|
|
58
|
+
Returns the source code of the generated contract, formatted in a Markdown code block. Does not write to disk.`;
|
|
59
|
+
}
|