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