@txtcel/mcp 0.1.1 → 0.1.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/README.md +0 -4
- package/dist/index.js +1 -168
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,10 +117,6 @@ Thread owner / admin: `init_thread_access`, `set_thread_access`,
|
|
|
117
117
|
`remove_from_whitelist`, `add_to_blacklist`, `remove_from_blacklist`,
|
|
118
118
|
`add_to_fee_whitelist`, `remove_from_fee_whitelist`, `sweep_author_fees`
|
|
119
119
|
|
|
120
|
-
Global admin (settings authority): `init_settings`, `set_treasury`, `set_admin`,
|
|
121
|
-
`set_base_fee`, `set_author_fee_cut`, `set_entry_cut`, `set_like_cut`,
|
|
122
|
-
`sweep_treasury`
|
|
123
|
-
|
|
124
120
|
Admin/owner tools succeed only when the agent wallet is the relevant authority;
|
|
125
121
|
otherwise the program rejects them with `Unauthorized`.
|
|
126
122
|
|
package/dist/index.js
CHANGED
|
@@ -48629,27 +48629,6 @@ function buildPrepareAllocInstruction(programId, payer, seed, allocSeq) {
|
|
|
48629
48629
|
}))
|
|
48630
48630
|
});
|
|
48631
48631
|
}
|
|
48632
|
-
function buildSweepTreasuryInstruction(programId, treasuryWallet, shardIndices) {
|
|
48633
|
-
const keys = [
|
|
48634
|
-
{ pubkey: deriveSettingsPda(programId), isSigner: false, isWritable: false },
|
|
48635
|
-
{ pubkey: treasuryWallet, isSigner: false, isWritable: true }
|
|
48636
|
-
];
|
|
48637
|
-
for (const idx of shardIndices) {
|
|
48638
|
-
keys.push({
|
|
48639
|
-
pubkey: deriveTreasuryShardPda(programId, idx),
|
|
48640
|
-
isSigner: false,
|
|
48641
|
-
isWritable: true
|
|
48642
|
-
});
|
|
48643
|
-
}
|
|
48644
|
-
return new TransactionInstruction({
|
|
48645
|
-
programId,
|
|
48646
|
-
keys,
|
|
48647
|
-
data: Buffer3.from(SweepTreasuryInstr.serialize({
|
|
48648
|
-
tag: Instruction.SweepTreasury,
|
|
48649
|
-
shardIndices: Uint16Array.from(shardIndices)
|
|
48650
|
-
}))
|
|
48651
|
-
});
|
|
48652
|
-
}
|
|
48653
48632
|
function buildSweepAuthorFeesInstruction(programId, seed, threadAccount, authorWallet, shardIndices) {
|
|
48654
48633
|
const keys = [
|
|
48655
48634
|
{ pubkey: threadAccount, isSigner: false, isWritable: false },
|
|
@@ -48685,41 +48664,6 @@ function buildCloseAccountInstruction(programId, payer, targetAccount, likesAcco
|
|
|
48685
48664
|
data: Buffer3.from(TagOnlyInstr.serialize({ tag: Instruction.CloseAccount }))
|
|
48686
48665
|
});
|
|
48687
48666
|
}
|
|
48688
|
-
function buildInitSettingsInstruction(programId, authority, treasury) {
|
|
48689
|
-
const BPF_LOADER_UPGRADEABLE_ID2 = new PublicKey("BPFLoaderUpgradeab1e11111111111111111111111");
|
|
48690
|
-
const [programdataAccount] = PublicKey.findProgramAddressSync(
|
|
48691
|
-
[programId.toBytes()],
|
|
48692
|
-
BPF_LOADER_UPGRADEABLE_ID2
|
|
48693
|
-
);
|
|
48694
|
-
const settingsAccount = deriveSettingsPda(programId);
|
|
48695
|
-
return new TransactionInstruction({
|
|
48696
|
-
programId,
|
|
48697
|
-
keys: [
|
|
48698
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
48699
|
-
{ pubkey: settingsAccount, isSigner: false, isWritable: true },
|
|
48700
|
-
{ pubkey: programdataAccount, isSigner: false, isWritable: false },
|
|
48701
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false }
|
|
48702
|
-
],
|
|
48703
|
-
data: Buffer3.from(TreasuryArgInstr.serialize({
|
|
48704
|
-
tag: Instruction.InitSettings,
|
|
48705
|
-
treasury: treasury.toBytes()
|
|
48706
|
-
}))
|
|
48707
|
-
});
|
|
48708
|
-
}
|
|
48709
|
-
function buildSetTreasuryInstruction(programId, authority, treasury) {
|
|
48710
|
-
const settingsAccount = deriveSettingsPda(programId);
|
|
48711
|
-
return new TransactionInstruction({
|
|
48712
|
-
programId,
|
|
48713
|
-
keys: [
|
|
48714
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
48715
|
-
{ pubkey: settingsAccount, isSigner: false, isWritable: true }
|
|
48716
|
-
],
|
|
48717
|
-
data: Buffer3.from(TreasuryArgInstr.serialize({
|
|
48718
|
-
tag: Instruction.SetTreasury,
|
|
48719
|
-
treasury: treasury.toBytes()
|
|
48720
|
-
}))
|
|
48721
|
-
});
|
|
48722
|
-
}
|
|
48723
48667
|
function buildInitThreadAccessInstruction(programId, authority, seed, enabled) {
|
|
48724
48668
|
const threadAccount = deriveThreadPda(programId, seed);
|
|
48725
48669
|
const accessAccount = deriveAccessPda(programId, seed);
|
|
@@ -48945,37 +48889,12 @@ function buildRemoveFromFeeWhitelistInstruction(programId, authority, seed, wall
|
|
|
48945
48889
|
}))
|
|
48946
48890
|
});
|
|
48947
48891
|
}
|
|
48948
|
-
function buildSetAdminInstruction(programId, authority, newAdmin) {
|
|
48949
|
-
const settingsAccount = deriveSettingsPda(programId);
|
|
48950
|
-
return new TransactionInstruction({
|
|
48951
|
-
programId,
|
|
48952
|
-
keys: [
|
|
48953
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
48954
|
-
{ pubkey: settingsAccount, isSigner: false, isWritable: true }
|
|
48955
|
-
],
|
|
48956
|
-
data: Buffer3.from(WalletArgInstr.serialize({
|
|
48957
|
-
tag: Instruction.SetAdmin,
|
|
48958
|
-
wallet: newAdmin.toBytes()
|
|
48959
|
-
}))
|
|
48960
|
-
});
|
|
48961
|
-
}
|
|
48962
48892
|
var FEE_TAG = {
|
|
48963
48893
|
base: Instruction.SetBaseFee,
|
|
48964
48894
|
authorCut: Instruction.SetAuthorFeeCut,
|
|
48965
48895
|
entryCut: Instruction.SetEntryCut,
|
|
48966
48896
|
likeCut: Instruction.SetLikeCut
|
|
48967
48897
|
};
|
|
48968
|
-
function buildSetFeeInstruction(programId, authority, kind, feeBps) {
|
|
48969
|
-
const settingsAccount = deriveSettingsPda(programId);
|
|
48970
|
-
return new TransactionInstruction({
|
|
48971
|
-
programId,
|
|
48972
|
-
keys: [
|
|
48973
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
48974
|
-
{ pubkey: settingsAccount, isSigner: false, isWritable: true }
|
|
48975
|
-
],
|
|
48976
|
-
data: Buffer3.from(FeeBpsInstr.serialize({ tag: FEE_TAG[kind], feeBps }))
|
|
48977
|
-
});
|
|
48978
|
-
}
|
|
48979
48898
|
function buildFollowInstruction(tag, opts) {
|
|
48980
48899
|
const { programId, user, seed } = opts;
|
|
48981
48900
|
const threadAccount = deriveThreadPda(programId, seed);
|
|
@@ -49721,101 +49640,15 @@ function registerThreadAdminTools(server) {
|
|
|
49721
49640
|
);
|
|
49722
49641
|
}
|
|
49723
49642
|
|
|
49724
|
-
// src/tools/globalAdmin.ts
|
|
49725
|
-
var feeBpsArg = external_exports.number().int().min(0).max(1e4).describe("Fee in basis points (0..10000, where 10000 = 100%).");
|
|
49726
|
-
function registerGlobalAdminTools(server) {
|
|
49727
|
-
server.registerTool(
|
|
49728
|
-
"init_settings",
|
|
49729
|
-
{
|
|
49730
|
-
title: "Init program settings",
|
|
49731
|
-
description: "Initialize the global program settings (one-time). Requires the agent wallet to be the program upgrade authority.",
|
|
49732
|
-
inputSchema: { treasury: external_exports.string().describe("Treasury wallet address (base58).") }
|
|
49733
|
-
},
|
|
49734
|
-
handler(async ({ treasury }) => {
|
|
49735
|
-
const { programId } = loadConfig();
|
|
49736
|
-
const payer = loadWallet();
|
|
49737
|
-
const ix = buildInitSettingsInstruction(programId, payer.publicKey, new PublicKey(treasury));
|
|
49738
|
-
const signature = await sendInstructions(payer, [ix]);
|
|
49739
|
-
return jsonResult({ signature, explorer: explorerTx(signature) });
|
|
49740
|
-
})
|
|
49741
|
-
);
|
|
49742
|
-
server.registerTool(
|
|
49743
|
-
"set_treasury",
|
|
49744
|
-
{
|
|
49745
|
-
title: "Set treasury",
|
|
49746
|
-
description: "Set the treasury wallet in program settings. Requires the agent wallet to be the settings admin.",
|
|
49747
|
-
inputSchema: { treasury: external_exports.string().describe("New treasury wallet address (base58).") }
|
|
49748
|
-
},
|
|
49749
|
-
handler(async ({ treasury }) => {
|
|
49750
|
-
const { programId } = loadConfig();
|
|
49751
|
-
const payer = loadWallet();
|
|
49752
|
-
const ix = buildSetTreasuryInstruction(programId, payer.publicKey, new PublicKey(treasury));
|
|
49753
|
-
const signature = await sendInstructions(payer, [ix]);
|
|
49754
|
-
return jsonResult({ signature, explorer: explorerTx(signature) });
|
|
49755
|
-
})
|
|
49756
|
-
);
|
|
49757
|
-
server.registerTool(
|
|
49758
|
-
"set_admin",
|
|
49759
|
-
{
|
|
49760
|
-
title: "Set admin",
|
|
49761
|
-
description: "Transfer the settings admin role to a new wallet. Requires the current admin.",
|
|
49762
|
-
inputSchema: { newAdmin: external_exports.string().describe("New admin wallet address (base58).") }
|
|
49763
|
-
},
|
|
49764
|
-
handler(async ({ newAdmin }) => {
|
|
49765
|
-
const { programId } = loadConfig();
|
|
49766
|
-
const payer = loadWallet();
|
|
49767
|
-
const ix = buildSetAdminInstruction(programId, payer.publicKey, new PublicKey(newAdmin));
|
|
49768
|
-
const signature = await sendInstructions(payer, [ix]);
|
|
49769
|
-
return jsonResult({ signature, explorer: explorerTx(signature) });
|
|
49770
|
-
})
|
|
49771
|
-
);
|
|
49772
|
-
const feeCutTool = (name, title, kind, description) => {
|
|
49773
|
-
server.registerTool(
|
|
49774
|
-
name,
|
|
49775
|
-
{ title, description, inputSchema: { feeBps: feeBpsArg } },
|
|
49776
|
-
handler(async ({ feeBps }) => {
|
|
49777
|
-
const { programId } = loadConfig();
|
|
49778
|
-
const payer = loadWallet();
|
|
49779
|
-
const ix = buildSetFeeInstruction(programId, payer.publicKey, kind, feeBps);
|
|
49780
|
-
const signature = await sendInstructions(payer, [ix]);
|
|
49781
|
-
return jsonResult({ signature, explorer: explorerTx(signature) });
|
|
49782
|
-
})
|
|
49783
|
-
);
|
|
49784
|
-
};
|
|
49785
|
-
feeCutTool("set_base_fee", "Set base fee", "base", "Set the platform base fee (BPS of content rent). Requires settings admin.");
|
|
49786
|
-
feeCutTool("set_author_fee_cut", "Set author fee cut", "authorCut", "Set the platform cut of author fees (BPS). Requires settings admin.");
|
|
49787
|
-
feeCutTool("set_entry_cut", "Set entry cut", "entryCut", "Set the platform cut of entry fees (BPS). Requires settings admin.");
|
|
49788
|
-
feeCutTool("set_like_cut", "Set like cut", "likeCut", "Set the platform cut of like fees (BPS). Requires settings admin.");
|
|
49789
|
-
server.registerTool(
|
|
49790
|
-
"sweep_treasury",
|
|
49791
|
-
{
|
|
49792
|
-
title: "Sweep treasury",
|
|
49793
|
-
description: "Sweep accumulated platform commission from treasury shards into the treasury wallet (must equal settings.treasury).",
|
|
49794
|
-
inputSchema: {
|
|
49795
|
-
treasury: external_exports.string().describe("Treasury wallet address (must equal settings.treasury)."),
|
|
49796
|
-
shardIndices: external_exports.array(external_exports.number().int().min(0).max(511)).min(1).describe("Treasury shard indices to sweep (0..511).")
|
|
49797
|
-
}
|
|
49798
|
-
},
|
|
49799
|
-
handler(async ({ treasury, shardIndices }) => {
|
|
49800
|
-
const { programId } = loadConfig();
|
|
49801
|
-
const payer = loadWallet();
|
|
49802
|
-
const ix = buildSweepTreasuryInstruction(programId, new PublicKey(treasury), shardIndices);
|
|
49803
|
-
const signature = await sendInstructions(payer, [ix]);
|
|
49804
|
-
return jsonResult({ signature, explorer: explorerTx(signature) });
|
|
49805
|
-
})
|
|
49806
|
-
);
|
|
49807
|
-
}
|
|
49808
|
-
|
|
49809
49643
|
// src/index.ts
|
|
49810
49644
|
async function main() {
|
|
49811
49645
|
const config2 = loadConfig();
|
|
49812
49646
|
const wallet = loadWallet();
|
|
49813
|
-
const server = new McpServer({ name: "txtcel-mcp", version: "0.1.
|
|
49647
|
+
const server = new McpServer({ name: "txtcel-mcp", version: "0.1.2" });
|
|
49814
49648
|
registerMessagingTools(server);
|
|
49815
49649
|
registerFollowTools(server);
|
|
49816
49650
|
registerReadTools(server);
|
|
49817
49651
|
registerThreadAdminTools(server);
|
|
49818
|
-
registerGlobalAdminTools(server);
|
|
49819
49652
|
const transport = new StdioServerTransport();
|
|
49820
49653
|
await server.connect(transport);
|
|
49821
49654
|
process.stderr.write(
|