@indigoprotocol/indigo-mcp 0.3.0 → 0.4.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/README.md +34 -17
- package/dist/cardano_multiplatform_lib_bg.wasm +0 -0
- package/dist/cli/setup.js +2 -2
- package/dist/index.js +378 -85
- package/dist/server.d.ts.map +1 -1
- package/dist/tools/cdp-liquidation-tools.d.ts.map +1 -1
- package/dist/tools/cdp-mint-burn-tools.d.ts.map +1 -1
- package/dist/tools/cdp-write-tools.d.ts.map +1 -1
- package/dist/tools/leverage-cdp-tools.d.ts.map +1 -1
- package/dist/tools/oracle-tools.d.ts.map +1 -1
- package/dist/tools/rob-write-tools.d.ts.map +1 -1
- package/dist/types/tx-types.d.ts +14 -0
- package/dist/types/tx-types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/indexer-client.d.ts +17 -0
- package/dist/utils/indexer-client.d.ts.map +1 -1
- package/dist/utils/pyth.d.ts +87 -0
- package/dist/utils/pyth.d.ts.map +1 -0
- package/dist/utils/tx-builder.d.ts +10 -2
- package/dist/utils/tx-builder.d.ts.map +1 -1
- package/dist/utils/v3-finders.d.ts +4 -3
- package/dist/utils/v3-finders.d.ts.map +1 -1
- package/dist/utils/validators.d.ts +1 -1
- package/dist/utils/validators.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ function getIndigoServerConfig() {
|
|
|
63
63
|
args: ["-y", "@indigoprotocol/indigo-mcp"],
|
|
64
64
|
env: {
|
|
65
65
|
PATH: `${nodePath}:/usr/local/bin:/usr/bin:/bin`,
|
|
66
|
-
INDEXER_URL: "https://analytics.indigoprotocol.io/api
|
|
66
|
+
INDEXER_URL: "https://analytics.indigoprotocol.io/api",
|
|
67
67
|
BLOCKFROST_API_KEY: ""
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -72,7 +72,7 @@ function getIndigoServerConfig() {
|
|
|
72
72
|
command: "npx",
|
|
73
73
|
args: ["-y", "@indigoprotocol/indigo-mcp"],
|
|
74
74
|
env: {
|
|
75
|
-
INDEXER_URL: "https://analytics.indigoprotocol.io/api
|
|
75
|
+
INDEXER_URL: "https://analytics.indigoprotocol.io/api",
|
|
76
76
|
BLOCKFROST_API_KEY: ""
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -39022,6 +39022,17 @@ var init_axios2 = __esm({
|
|
|
39022
39022
|
});
|
|
39023
39023
|
|
|
39024
39024
|
// src/utils/indexer-client.ts
|
|
39025
|
+
function normalizeIndexerUrl(url3) {
|
|
39026
|
+
const trimmed2 = url3.replace(/\/+$/, "");
|
|
39027
|
+
const withoutVersion = trimmed2.replace(/\/v\d+$/, "");
|
|
39028
|
+
if (withoutVersion !== trimmed2) {
|
|
39029
|
+
process.stderr.write(
|
|
39030
|
+
`Indigo MCP: INDEXER_URL "${url3}" ends in an API version; using "${withoutVersion}". Tool paths carry their own version \u2014 set the base URL without one.
|
|
39031
|
+
`
|
|
39032
|
+
);
|
|
39033
|
+
}
|
|
39034
|
+
return withoutVersion;
|
|
39035
|
+
}
|
|
39025
39036
|
function getIndexerClient() {
|
|
39026
39037
|
if (!instance) {
|
|
39027
39038
|
instance = axios_default.create({
|
|
@@ -39035,12 +39046,13 @@ function getIndexerClient() {
|
|
|
39035
39046
|
}
|
|
39036
39047
|
return instance;
|
|
39037
39048
|
}
|
|
39038
|
-
var INDEXER_URL, instance;
|
|
39049
|
+
var DEFAULT_INDEXER_URL, INDEXER_URL, instance;
|
|
39039
39050
|
var init_indexer_client = __esm({
|
|
39040
39051
|
"src/utils/indexer-client.ts"() {
|
|
39041
39052
|
"use strict";
|
|
39042
39053
|
init_axios2();
|
|
39043
|
-
|
|
39054
|
+
DEFAULT_INDEXER_URL = "https://analytics.indigoprotocol.io/api";
|
|
39055
|
+
INDEXER_URL = normalizeIndexerUrl(process.env.INDEXER_URL || DEFAULT_INDEXER_URL);
|
|
39044
39056
|
instance = null;
|
|
39045
39057
|
}
|
|
39046
39058
|
});
|
|
@@ -39182,7 +39194,7 @@ var init_validators = __esm({
|
|
|
39182
39194
|
"src/utils/validators.ts"() {
|
|
39183
39195
|
"use strict";
|
|
39184
39196
|
init_zod();
|
|
39185
|
-
AssetParam = external_exports.enum(["iUSD", "iBTC", "iETH", "iSOL", "iEUR", "iJPY"]);
|
|
39197
|
+
AssetParam = external_exports.enum(["iUSD", "iBTC", "iETH", "iSOL", "iEUR", "iJPY", "iADA"]);
|
|
39186
39198
|
}
|
|
39187
39199
|
});
|
|
39188
39200
|
|
|
@@ -238304,6 +238316,11 @@ var init_lucid_provider = __esm({
|
|
|
238304
238316
|
});
|
|
238305
238317
|
|
|
238306
238318
|
// src/utils/tx-builder.ts
|
|
238319
|
+
function describeError(error2) {
|
|
238320
|
+
if (error2 instanceof Error) return error2.message;
|
|
238321
|
+
const text = String(error2);
|
|
238322
|
+
return text === "[object Object]" ? JSON.stringify(error2) : text;
|
|
238323
|
+
}
|
|
238307
238324
|
function buildCip20Message(summary5) {
|
|
238308
238325
|
const lines = [`Indigo Protocol: ${summary5.type}`, summary5.description];
|
|
238309
238326
|
return lines.map((line) => line.length > 64 ? line.slice(0, 64) : line);
|
|
@@ -238312,24 +238329,38 @@ async function buildUnsignedTx(address, buildFn, summary5) {
|
|
|
238312
238329
|
const lucid3 = await getLucid();
|
|
238313
238330
|
const utxos = await lucid3.utxosAt(address);
|
|
238314
238331
|
lucid3.selectWallet.fromAddress(address, utxos);
|
|
238315
|
-
const
|
|
238316
|
-
|
|
238317
|
-
|
|
238318
|
-
|
|
238319
|
-
|
|
238332
|
+
const assemble2 = async (minFee) => {
|
|
238333
|
+
const ctx2 = {};
|
|
238334
|
+
const txBuilder = await buildFn(lucid3, ctx2);
|
|
238335
|
+
txBuilder.attachMetadata(CIP20_METADATA_LABEL, {
|
|
238336
|
+
msg: buildCip20Message(summary5)
|
|
238337
|
+
});
|
|
238338
|
+
if (minFee !== void 0) txBuilder.setMinFee(minFee);
|
|
238339
|
+
return { tx: await txBuilder.complete(), ctx: ctx2 };
|
|
238340
|
+
};
|
|
238341
|
+
let built;
|
|
238342
|
+
try {
|
|
238343
|
+
built = await assemble2();
|
|
238344
|
+
} catch (error2) {
|
|
238345
|
+
const hint = MIN_FEE_HINT.exec(describeError(error2));
|
|
238346
|
+
if (!hint) throw error2;
|
|
238347
|
+
built = await assemble2(BigInt(hint[1]));
|
|
238348
|
+
}
|
|
238349
|
+
const { tx, ctx } = built;
|
|
238320
238350
|
return {
|
|
238321
238351
|
unsignedTx: tx.toCBOR(),
|
|
238322
238352
|
txHash: tx.toHash(),
|
|
238323
238353
|
fee: tx.toTransaction().body().fee().toString(),
|
|
238324
|
-
summary: summary5
|
|
238354
|
+
summary: ctx.pyth ? { ...summary5, pyth: ctx.pyth } : summary5
|
|
238325
238355
|
};
|
|
238326
238356
|
}
|
|
238327
|
-
var CIP20_METADATA_LABEL;
|
|
238357
|
+
var CIP20_METADATA_LABEL, MIN_FEE_HINT;
|
|
238328
238358
|
var init_tx_builder = __esm({
|
|
238329
238359
|
"src/utils/tx-builder.ts"() {
|
|
238330
238360
|
"use strict";
|
|
238331
238361
|
init_lucid_provider();
|
|
238332
238362
|
CIP20_METADATA_LABEL = 674;
|
|
238363
|
+
MIN_FEE_HINT = /minimum fee of (\d+) lovelace/i;
|
|
238333
238364
|
}
|
|
238334
238365
|
});
|
|
238335
238366
|
|
|
@@ -238697,6 +238728,101 @@ var init_v3_finders = __esm({
|
|
|
238697
238728
|
}
|
|
238698
238729
|
});
|
|
238699
238730
|
|
|
238731
|
+
// src/utils/pyth.ts
|
|
238732
|
+
async function fetchPythPriceFeed(asset, collateral = DEFAULT_COLLATERAL) {
|
|
238733
|
+
const client = getIndexerClient();
|
|
238734
|
+
const path2 = `/v3/assets/${encodeURIComponent(asset)}/${encodeURIComponent(collateral)}/price`;
|
|
238735
|
+
const response = await client.get(path2);
|
|
238736
|
+
const { price, timestamp, pythPayload } = response.data ?? {};
|
|
238737
|
+
if (!pythPayload) {
|
|
238738
|
+
throw new Error(
|
|
238739
|
+
`No Pyth payload returned for ${asset}/${collateral} by the Indigo analytics API. The asset may not be priced via Pyth, or the feed is temporarily unavailable.`
|
|
238740
|
+
);
|
|
238741
|
+
}
|
|
238742
|
+
const timestampMs = timestamp * 1e3;
|
|
238743
|
+
return {
|
|
238744
|
+
price,
|
|
238745
|
+
pythMessage: pythPayload,
|
|
238746
|
+
timestampMs,
|
|
238747
|
+
validUntilMs: timestampMs + PYTH_MAX_DELAY_MS
|
|
238748
|
+
};
|
|
238749
|
+
}
|
|
238750
|
+
function assertPythFeedFresh(feed, asset, collateral = DEFAULT_COLLATERAL) {
|
|
238751
|
+
const ageMs = Date.now() - feed.timestampMs;
|
|
238752
|
+
if (ageMs <= PYTH_MAX_DELAY_MS) return;
|
|
238753
|
+
throw new Error(
|
|
238754
|
+
`The Pyth price message for ${asset}/${collateral} is ${Math.round(ageMs / 1e3)}s old, beyond the ${PYTH_MAX_DELAY_MS / 1e3}s on-chain validity window. Retry to pick up a fresher price update.`
|
|
238755
|
+
);
|
|
238756
|
+
}
|
|
238757
|
+
async function fetchPythStateOref() {
|
|
238758
|
+
const client = getIndexerClient();
|
|
238759
|
+
const response = await client.get("/v3/pyth-state/utxo");
|
|
238760
|
+
const { outputHash, outputIndex } = response.data ?? {};
|
|
238761
|
+
if (!outputHash || outputIndex === void 0 || outputIndex === null) {
|
|
238762
|
+
throw new Error("The Indigo analytics API did not return a Pyth state UTxO");
|
|
238763
|
+
}
|
|
238764
|
+
return { txHash: outputHash, outputIndex };
|
|
238765
|
+
}
|
|
238766
|
+
async function resolvePythStateOref(lucid3) {
|
|
238767
|
+
try {
|
|
238768
|
+
return await fetchPythStateOref();
|
|
238769
|
+
} catch (apiError) {
|
|
238770
|
+
try {
|
|
238771
|
+
const params = await getSystemParams();
|
|
238772
|
+
const unit = assetClassToUnit(fromSystemParamsAsset(params.pythConfig.pythStateAssetClass));
|
|
238773
|
+
const utxo = await lucid3.utxoByUnit(unit);
|
|
238774
|
+
return { txHash: utxo.txHash, outputIndex: utxo.outputIndex };
|
|
238775
|
+
} catch (chainError) {
|
|
238776
|
+
throw new Error(
|
|
238777
|
+
`Could not resolve the Pyth state UTxO from the analytics API (${apiError instanceof Error ? apiError.message : String(apiError)}) or from the chain (${chainError instanceof Error ? chainError.message : String(chainError)})`
|
|
238778
|
+
);
|
|
238779
|
+
}
|
|
238780
|
+
}
|
|
238781
|
+
}
|
|
238782
|
+
async function resolvePriceSource(lucid3, collateralAsset, asset, collateral = DEFAULT_COLLATERAL) {
|
|
238783
|
+
const priceOracleOref = await findPriceOracleOref(lucid3, collateralAsset);
|
|
238784
|
+
if (priceOracleOref !== void 0) {
|
|
238785
|
+
return {
|
|
238786
|
+
priceOracleOref,
|
|
238787
|
+
pythMessage: void 0,
|
|
238788
|
+
pythStateOref: void 0,
|
|
238789
|
+
pythFeed: void 0
|
|
238790
|
+
};
|
|
238791
|
+
}
|
|
238792
|
+
const [pythFeed, pythStateOref] = await Promise.all([
|
|
238793
|
+
fetchPythPriceFeed(asset, collateral),
|
|
238794
|
+
resolvePythStateOref(lucid3)
|
|
238795
|
+
]);
|
|
238796
|
+
assertPythFeedFresh(pythFeed, asset, collateral);
|
|
238797
|
+
return {
|
|
238798
|
+
priceOracleOref: void 0,
|
|
238799
|
+
pythMessage: pythFeed.pythMessage,
|
|
238800
|
+
pythStateOref,
|
|
238801
|
+
pythFeed
|
|
238802
|
+
};
|
|
238803
|
+
}
|
|
238804
|
+
function pythSummary(source) {
|
|
238805
|
+
if (!source.pythFeed) return void 0;
|
|
238806
|
+
return {
|
|
238807
|
+
price: source.pythFeed.price,
|
|
238808
|
+
priceTimestamp: new Date(source.pythFeed.timestampMs).toISOString(),
|
|
238809
|
+
submitBefore: new Date(source.pythFeed.validUntilMs).toISOString()
|
|
238810
|
+
};
|
|
238811
|
+
}
|
|
238812
|
+
var DEFAULT_COLLATERAL, PYTH_MAX_DELAY_MS;
|
|
238813
|
+
var init_pyth = __esm({
|
|
238814
|
+
"src/utils/pyth.ts"() {
|
|
238815
|
+
"use strict";
|
|
238816
|
+
init_dist14();
|
|
238817
|
+
init_src();
|
|
238818
|
+
init_indexer_client();
|
|
238819
|
+
init_sdk_config();
|
|
238820
|
+
init_v3_finders();
|
|
238821
|
+
DEFAULT_COLLATERAL = "ada";
|
|
238822
|
+
PYTH_MAX_DELAY_MS = 280 * 1e3;
|
|
238823
|
+
}
|
|
238824
|
+
});
|
|
238825
|
+
|
|
238700
238826
|
// src/tools/cdp-mint-burn-tools.ts
|
|
238701
238827
|
function registerCdpMintBurnTools(server) {
|
|
238702
238828
|
server.tool(
|
|
@@ -238713,7 +238839,7 @@ function registerCdpMintBurnTools(server) {
|
|
|
238713
238839
|
try {
|
|
238714
238840
|
const result = await buildUnsignedTx(
|
|
238715
238841
|
address,
|
|
238716
|
-
async (lucid3) => {
|
|
238842
|
+
async (lucid3, ctx) => {
|
|
238717
238843
|
const params = await getSystemParams();
|
|
238718
238844
|
const currentSlot = lucid3.currentSlot();
|
|
238719
238845
|
const cdpOref = { txHash: cdpTxHash, outputIndex: cdpOutputIndex };
|
|
@@ -238723,23 +238849,25 @@ function registerCdpMintBurnTools(server) {
|
|
|
238723
238849
|
findInterestCollectorOref(lucid3, params),
|
|
238724
238850
|
findTreasuryOref(lucid3, params)
|
|
238725
238851
|
]);
|
|
238726
|
-
const [
|
|
238727
|
-
|
|
238852
|
+
const [priceSource, interestOracleOref] = await Promise.all([
|
|
238853
|
+
resolvePriceSource(lucid3, collateralOut, asset),
|
|
238728
238854
|
findInterestOracleOref(lucid3, collateralOut)
|
|
238729
238855
|
]);
|
|
238730
|
-
|
|
238856
|
+
ctx.pyth = pythSummary(priceSource);
|
|
238731
238857
|
return mintCdp(
|
|
238732
238858
|
BigInt(amount),
|
|
238733
238859
|
cdpOref,
|
|
238734
238860
|
toOutRef(iassetOut.utxo),
|
|
238735
238861
|
toOutRef(collateralOut.utxo),
|
|
238736
|
-
priceOracleOref,
|
|
238862
|
+
priceSource.priceOracleOref,
|
|
238737
238863
|
interestOracleOref,
|
|
238738
238864
|
treasuryOref,
|
|
238739
238865
|
interestCollectorOref,
|
|
238740
238866
|
params,
|
|
238741
238867
|
lucid3,
|
|
238742
|
-
currentSlot
|
|
238868
|
+
currentSlot,
|
|
238869
|
+
priceSource.pythMessage,
|
|
238870
|
+
priceSource.pythStateOref
|
|
238743
238871
|
);
|
|
238744
238872
|
},
|
|
238745
238873
|
{
|
|
@@ -238825,7 +238953,6 @@ function registerCdpMintBurnTools(server) {
|
|
|
238825
238953
|
}
|
|
238826
238954
|
);
|
|
238827
238955
|
}
|
|
238828
|
-
var PYTH_UNSUPPORTED;
|
|
238829
238956
|
var init_cdp_mint_burn_tools = __esm({
|
|
238830
238957
|
"src/tools/cdp-mint-burn-tools.ts"() {
|
|
238831
238958
|
"use strict";
|
|
@@ -238835,7 +238962,7 @@ var init_cdp_mint_burn_tools = __esm({
|
|
|
238835
238962
|
init_sdk_config();
|
|
238836
238963
|
init_validators();
|
|
238837
238964
|
init_v3_finders();
|
|
238838
|
-
|
|
238965
|
+
init_pyth();
|
|
238839
238966
|
}
|
|
238840
238967
|
});
|
|
238841
238968
|
|
|
@@ -238854,7 +238981,7 @@ function registerCdpWriteTools(server) {
|
|
|
238854
238981
|
try {
|
|
238855
238982
|
const result = await buildUnsignedTx(
|
|
238856
238983
|
address,
|
|
238857
|
-
async (lucid3) => {
|
|
238984
|
+
async (lucid3, ctx) => {
|
|
238858
238985
|
const params = await getSystemParams();
|
|
238859
238986
|
const currentSlot = lucid3.currentSlot();
|
|
238860
238987
|
const [iassetOut, collateralOut, cdpCreatorOref, treasuryOref] = await Promise.all([
|
|
@@ -238863,11 +238990,11 @@ function registerCdpWriteTools(server) {
|
|
|
238863
238990
|
findCdpCreatorOref(lucid3, params),
|
|
238864
238991
|
findTreasuryOref(lucid3, params)
|
|
238865
238992
|
]);
|
|
238866
|
-
const [
|
|
238867
|
-
|
|
238993
|
+
const [priceSource, interestOracleOref] = await Promise.all([
|
|
238994
|
+
resolvePriceSource(lucid3, collateralOut, asset),
|
|
238868
238995
|
findInterestOracleOref(lucid3, collateralOut)
|
|
238869
238996
|
]);
|
|
238870
|
-
|
|
238997
|
+
ctx.pyth = pythSummary(priceSource);
|
|
238871
238998
|
return openCdp(
|
|
238872
238999
|
BigInt(collateralAmount),
|
|
238873
239000
|
BigInt(mintAmount),
|
|
@@ -238875,11 +239002,13 @@ function registerCdpWriteTools(server) {
|
|
|
238875
239002
|
cdpCreatorOref,
|
|
238876
239003
|
toOutRef(iassetOut.utxo),
|
|
238877
239004
|
toOutRef(collateralOut.utxo),
|
|
238878
|
-
priceOracleOref,
|
|
239005
|
+
priceSource.priceOracleOref,
|
|
238879
239006
|
interestOracleOref,
|
|
238880
239007
|
treasuryOref,
|
|
238881
239008
|
lucid3,
|
|
238882
|
-
currentSlot
|
|
239009
|
+
currentSlot,
|
|
239010
|
+
priceSource.pythMessage,
|
|
239011
|
+
priceSource.pythStateOref
|
|
238883
239012
|
);
|
|
238884
239013
|
},
|
|
238885
239014
|
{
|
|
@@ -238978,7 +239107,7 @@ function registerCdpWriteTools(server) {
|
|
|
238978
239107
|
try {
|
|
238979
239108
|
const result = await buildUnsignedTx(
|
|
238980
239109
|
address,
|
|
238981
|
-
async (lucid3) => {
|
|
239110
|
+
async (lucid3, ctx) => {
|
|
238982
239111
|
const params = await getSystemParams();
|
|
238983
239112
|
const currentSlot = lucid3.currentSlot();
|
|
238984
239113
|
const cdpOref = { txHash: cdpTxHash, outputIndex: cdpOutputIndex };
|
|
@@ -238988,23 +239117,25 @@ function registerCdpWriteTools(server) {
|
|
|
238988
239117
|
findInterestCollectorOref(lucid3, params),
|
|
238989
239118
|
findTreasuryOref(lucid3, params)
|
|
238990
239119
|
]);
|
|
238991
|
-
const [
|
|
238992
|
-
|
|
239120
|
+
const [priceSource, interestOracleOref] = await Promise.all([
|
|
239121
|
+
resolvePriceSource(lucid3, collateralOut, asset),
|
|
238993
239122
|
findInterestOracleOref(lucid3, collateralOut)
|
|
238994
239123
|
]);
|
|
238995
|
-
|
|
239124
|
+
ctx.pyth = pythSummary(priceSource);
|
|
238996
239125
|
return withdrawCdp(
|
|
238997
239126
|
BigInt(amount),
|
|
238998
239127
|
cdpOref,
|
|
238999
239128
|
toOutRef(iassetOut.utxo),
|
|
239000
239129
|
toOutRef(collateralOut.utxo),
|
|
239001
|
-
priceOracleOref,
|
|
239130
|
+
priceSource.priceOracleOref,
|
|
239002
239131
|
interestOracleOref,
|
|
239003
239132
|
treasuryOref,
|
|
239004
239133
|
interestCollectorOref,
|
|
239005
239134
|
params,
|
|
239006
239135
|
lucid3,
|
|
239007
|
-
currentSlot
|
|
239136
|
+
currentSlot,
|
|
239137
|
+
priceSource.pythMessage,
|
|
239138
|
+
priceSource.pythStateOref
|
|
239008
239139
|
);
|
|
239009
239140
|
},
|
|
239010
239141
|
{
|
|
@@ -239084,7 +239215,6 @@ function registerCdpWriteTools(server) {
|
|
|
239084
239215
|
}
|
|
239085
239216
|
);
|
|
239086
239217
|
}
|
|
239087
|
-
var PYTH_UNSUPPORTED2;
|
|
239088
239218
|
var init_cdp_write_tools = __esm({
|
|
239089
239219
|
"src/tools/cdp-write-tools.ts"() {
|
|
239090
239220
|
"use strict";
|
|
@@ -239094,7 +239224,7 @@ var init_cdp_write_tools = __esm({
|
|
|
239094
239224
|
init_sdk_config();
|
|
239095
239225
|
init_validators();
|
|
239096
239226
|
init_v3_finders();
|
|
239097
|
-
|
|
239227
|
+
init_pyth();
|
|
239098
239228
|
}
|
|
239099
239229
|
});
|
|
239100
239230
|
|
|
@@ -240035,7 +240165,7 @@ function registerCdpLiquidationTools(server) {
|
|
|
240035
240165
|
try {
|
|
240036
240166
|
const result = await buildUnsignedTx(
|
|
240037
240167
|
address,
|
|
240038
|
-
async (lucid3) => {
|
|
240168
|
+
async (lucid3, ctx) => {
|
|
240039
240169
|
const params = await getSystemParams();
|
|
240040
240170
|
const currentSlot = lucid3.currentSlot();
|
|
240041
240171
|
const cdpOref = { txHash: cdpTxHash, outputIndex: cdpOutputIndex };
|
|
@@ -240046,24 +240176,26 @@ function registerCdpLiquidationTools(server) {
|
|
|
240046
240176
|
findTreasuryOref(lucid3, params),
|
|
240047
240177
|
findGov(lucid3, params)
|
|
240048
240178
|
]);
|
|
240049
|
-
const [
|
|
240050
|
-
|
|
240179
|
+
const [priceSource, interestOracleOref] = await Promise.all([
|
|
240180
|
+
resolvePriceSource(lucid3, collateralOut, asset),
|
|
240051
240181
|
findInterestOracleOref(lucid3, collateralOut)
|
|
240052
240182
|
]);
|
|
240053
|
-
|
|
240183
|
+
ctx.pyth = pythSummary(priceSource);
|
|
240054
240184
|
return redeemCdp(
|
|
240055
240185
|
BigInt(amount),
|
|
240056
240186
|
cdpOref,
|
|
240057
240187
|
toOutRef(iassetOut.utxo),
|
|
240058
240188
|
toOutRef(collateralOut.utxo),
|
|
240059
|
-
priceOracleOref,
|
|
240189
|
+
priceSource.priceOracleOref,
|
|
240060
240190
|
interestOracleOref,
|
|
240061
240191
|
interestCollectorOref,
|
|
240062
240192
|
treasuryOref,
|
|
240063
240193
|
toOutRef(gov.utxo),
|
|
240064
240194
|
params,
|
|
240065
240195
|
lucid3,
|
|
240066
|
-
currentSlot
|
|
240196
|
+
currentSlot,
|
|
240197
|
+
priceSource.pythMessage,
|
|
240198
|
+
priceSource.pythStateOref
|
|
240067
240199
|
);
|
|
240068
240200
|
},
|
|
240069
240201
|
{
|
|
@@ -240101,7 +240233,7 @@ function registerCdpLiquidationTools(server) {
|
|
|
240101
240233
|
try {
|
|
240102
240234
|
const result = await buildUnsignedTx(
|
|
240103
240235
|
address,
|
|
240104
|
-
async (lucid3) => {
|
|
240236
|
+
async (lucid3, ctx) => {
|
|
240105
240237
|
const params = await getSystemParams();
|
|
240106
240238
|
const currentSlot = lucid3.currentSlot();
|
|
240107
240239
|
const cdpOref = { txHash: cdpTxHash, outputIndex: cdpOutputIndex };
|
|
@@ -240109,20 +240241,22 @@ function registerCdpLiquidationTools(server) {
|
|
|
240109
240241
|
findIAsset(lucid3, params, asset),
|
|
240110
240242
|
findCollateralAsset(lucid3, params, asset)
|
|
240111
240243
|
]);
|
|
240112
|
-
const [
|
|
240113
|
-
|
|
240244
|
+
const [priceSource, interestOracleOref] = await Promise.all([
|
|
240245
|
+
resolvePriceSource(lucid3, collateralOut, asset),
|
|
240114
240246
|
findInterestOracleOref(lucid3, collateralOut)
|
|
240115
240247
|
]);
|
|
240116
|
-
|
|
240248
|
+
ctx.pyth = pythSummary(priceSource);
|
|
240117
240249
|
return freezeCdp(
|
|
240118
240250
|
cdpOref,
|
|
240119
240251
|
toOutRef(iassetOut.utxo),
|
|
240120
240252
|
toOutRef(collateralOut.utxo),
|
|
240121
|
-
priceOracleOref,
|
|
240253
|
+
priceSource.priceOracleOref,
|
|
240122
240254
|
interestOracleOref,
|
|
240123
240255
|
params,
|
|
240124
240256
|
lucid3,
|
|
240125
|
-
currentSlot
|
|
240257
|
+
currentSlot,
|
|
240258
|
+
priceSource.pythMessage,
|
|
240259
|
+
priceSource.pythStateOref
|
|
240126
240260
|
);
|
|
240127
240261
|
},
|
|
240128
240262
|
{
|
|
@@ -240190,7 +240324,6 @@ function registerCdpLiquidationTools(server) {
|
|
|
240190
240324
|
}
|
|
240191
240325
|
);
|
|
240192
240326
|
}
|
|
240193
|
-
var PYTH_UNSUPPORTED3;
|
|
240194
240327
|
var init_cdp_liquidation_tools = __esm({
|
|
240195
240328
|
"src/tools/cdp-liquidation-tools.ts"() {
|
|
240196
240329
|
"use strict";
|
|
@@ -240200,7 +240333,7 @@ var init_cdp_liquidation_tools = __esm({
|
|
|
240200
240333
|
init_sdk_config();
|
|
240201
240334
|
init_validators();
|
|
240202
240335
|
init_v3_finders();
|
|
240203
|
-
|
|
240336
|
+
init_pyth();
|
|
240204
240337
|
}
|
|
240205
240338
|
});
|
|
240206
240339
|
|
|
@@ -240219,7 +240352,7 @@ function registerLeverageCdpTools(server) {
|
|
|
240219
240352
|
try {
|
|
240220
240353
|
const result = await buildUnsignedTx(
|
|
240221
240354
|
address,
|
|
240222
|
-
async (lucid3) => {
|
|
240355
|
+
async (lucid3, ctx) => {
|
|
240223
240356
|
const params = await getSystemParams();
|
|
240224
240357
|
const currentSlot = lucid3.currentSlot();
|
|
240225
240358
|
const [iassetOut, collateralOut, cdpCreatorOref, treasuryOref, allRobs] = await Promise.all([
|
|
@@ -240235,15 +240368,15 @@ function registerLeverageCdpTools(server) {
|
|
|
240235
240368
|
if (treasuryOref === void 0) {
|
|
240236
240369
|
throw new Error("No ADA-only treasury UTxO available for leverage operation");
|
|
240237
240370
|
}
|
|
240238
|
-
const [
|
|
240239
|
-
|
|
240371
|
+
const [priceSource, interestOracleOref] = await Promise.all([
|
|
240372
|
+
resolvePriceSource(lucid3, collateralOut, asset),
|
|
240240
240373
|
findInterestOracleOref(lucid3, collateralOut)
|
|
240241
240374
|
]);
|
|
240242
|
-
|
|
240375
|
+
ctx.pyth = pythSummary(priceSource);
|
|
240243
240376
|
return leverageCdpWithRob(
|
|
240244
240377
|
leverage,
|
|
240245
240378
|
BigInt(baseCollateral),
|
|
240246
|
-
priceOracleOref,
|
|
240379
|
+
priceSource.priceOracleOref,
|
|
240247
240380
|
toOutRef(iassetOut.utxo),
|
|
240248
240381
|
toOutRef(collateralOut.utxo),
|
|
240249
240382
|
cdpCreatorOref,
|
|
@@ -240252,7 +240385,9 @@ function registerLeverageCdpTools(server) {
|
|
|
240252
240385
|
params,
|
|
240253
240386
|
lucid3,
|
|
240254
240387
|
allRobs,
|
|
240255
|
-
currentSlot
|
|
240388
|
+
currentSlot,
|
|
240389
|
+
priceSource.pythMessage,
|
|
240390
|
+
priceSource.pythStateOref
|
|
240256
240391
|
);
|
|
240257
240392
|
},
|
|
240258
240393
|
{
|
|
@@ -240278,7 +240413,6 @@ function registerLeverageCdpTools(server) {
|
|
|
240278
240413
|
}
|
|
240279
240414
|
);
|
|
240280
240415
|
}
|
|
240281
|
-
var PYTH_UNSUPPORTED4;
|
|
240282
240416
|
var init_leverage_cdp_tools = __esm({
|
|
240283
240417
|
"src/tools/leverage-cdp-tools.ts"() {
|
|
240284
240418
|
"use strict";
|
|
@@ -240288,7 +240422,7 @@ var init_leverage_cdp_tools = __esm({
|
|
|
240288
240422
|
init_sdk_config();
|
|
240289
240423
|
init_validators();
|
|
240290
240424
|
init_v3_finders();
|
|
240291
|
-
|
|
240425
|
+
init_pyth();
|
|
240292
240426
|
}
|
|
240293
240427
|
});
|
|
240294
240428
|
|
|
@@ -240509,27 +240643,29 @@ function registerRobWriteTools(server) {
|
|
|
240509
240643
|
try {
|
|
240510
240644
|
const result = await buildUnsignedTx(
|
|
240511
240645
|
address,
|
|
240512
|
-
async (lucid3) => {
|
|
240646
|
+
async (lucid3, ctx) => {
|
|
240513
240647
|
const params = await getSystemParams();
|
|
240514
240648
|
const currentSlot = lucid3.currentSlot();
|
|
240515
240649
|
const [iassetOut, collateralOut] = await Promise.all([
|
|
240516
240650
|
findIAsset(lucid3, params, asset),
|
|
240517
240651
|
findCollateralAsset(lucid3, params, asset)
|
|
240518
240652
|
]);
|
|
240519
|
-
const
|
|
240520
|
-
|
|
240653
|
+
const priceSource = await resolvePriceSource(lucid3, collateralOut, asset);
|
|
240654
|
+
ctx.pyth = pythSummary(priceSource);
|
|
240521
240655
|
const redemptionRobsData = redemptionRobs.map((rob) => [
|
|
240522
240656
|
{ txHash: rob.txHash, outputIndex: rob.outputIndex },
|
|
240523
240657
|
BigInt(rob.amount)
|
|
240524
240658
|
]);
|
|
240525
240659
|
return redeemRob(
|
|
240526
240660
|
redemptionRobsData,
|
|
240527
|
-
priceOracleOref,
|
|
240661
|
+
priceSource.priceOracleOref,
|
|
240528
240662
|
toOutRef(iassetOut.utxo),
|
|
240529
240663
|
toOutRef(collateralOut.utxo),
|
|
240530
240664
|
lucid3,
|
|
240531
240665
|
params,
|
|
240532
|
-
currentSlot
|
|
240666
|
+
currentSlot,
|
|
240667
|
+
priceSource.pythMessage,
|
|
240668
|
+
priceSource.pythStateOref
|
|
240533
240669
|
);
|
|
240534
240670
|
},
|
|
240535
240671
|
{
|
|
@@ -240555,7 +240691,6 @@ function registerRobWriteTools(server) {
|
|
|
240555
240691
|
}
|
|
240556
240692
|
);
|
|
240557
240693
|
}
|
|
240558
|
-
var PYTH_UNSUPPORTED5;
|
|
240559
240694
|
var init_rob_write_tools = __esm({
|
|
240560
240695
|
"src/tools/rob-write-tools.ts"() {
|
|
240561
240696
|
"use strict";
|
|
@@ -240565,7 +240700,7 @@ var init_rob_write_tools = __esm({
|
|
|
240565
240700
|
init_sdk_config();
|
|
240566
240701
|
init_validators();
|
|
240567
240702
|
init_v3_finders();
|
|
240568
|
-
|
|
240703
|
+
init_pyth();
|
|
240569
240704
|
}
|
|
240570
240705
|
});
|
|
240571
240706
|
|
|
@@ -241079,7 +241214,7 @@ function registerOracleTools(server) {
|
|
|
241079
241214
|
);
|
|
241080
241215
|
server.tool(
|
|
241081
241216
|
"get_pyth_price",
|
|
241082
|
-
"
|
|
241217
|
+
"Get the current Pyth price for an iAsset, together with its on-chain feed configuration. The price is the latest signed Pyth update served by the Indigo analytics API \u2014 the same payload the CDP write tools embed on-chain \u2014 and is only valid on-chain until validUntil.",
|
|
241083
241218
|
{ asset: AssetParam },
|
|
241084
241219
|
async ({ asset }) => {
|
|
241085
241220
|
try {
|
|
@@ -241180,6 +241315,20 @@ async function getPythPriceForAsset(asset) {
|
|
|
241180
241315
|
const lucid3 = await getLucid();
|
|
241181
241316
|
const params = await getSystemParams();
|
|
241182
241317
|
const pythConfig = params.pythConfig;
|
|
241318
|
+
let livePrice;
|
|
241319
|
+
try {
|
|
241320
|
+
const feed = await fetchPythPriceFeed(asset);
|
|
241321
|
+
livePrice = {
|
|
241322
|
+
price: feed.price,
|
|
241323
|
+
priceTimestamp: new Date(feed.timestampMs).toISOString(),
|
|
241324
|
+
validUntil: new Date(feed.validUntilMs).toISOString(),
|
|
241325
|
+
stale: Date.now() > feed.validUntilMs
|
|
241326
|
+
};
|
|
241327
|
+
} catch (error2) {
|
|
241328
|
+
livePrice = {
|
|
241329
|
+
error: `Could not fetch the live Pyth price: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
241330
|
+
};
|
|
241331
|
+
}
|
|
241183
241332
|
const iassetBytes = fromText(asset);
|
|
241184
241333
|
const iassetUint8 = Buffer.from(iassetBytes, "hex");
|
|
241185
241334
|
let feedConfig;
|
|
@@ -241187,6 +241336,7 @@ async function getPythPriceForAsset(asset) {
|
|
|
241187
241336
|
feedConfig = getPythFeedConfig(pythConfig, iassetUint8, ADA_COLLATERAL);
|
|
241188
241337
|
} catch {
|
|
241189
241338
|
return {
|
|
241339
|
+
...livePrice,
|
|
241190
241340
|
note: `No Pyth feed config found for ${asset}. The asset may not be priced via Pyth, or the key lookup failed.`,
|
|
241191
241341
|
pythStateAssetClass: pythConfig.pythStateAssetClass
|
|
241192
241342
|
};
|
|
@@ -241204,12 +241354,13 @@ async function getPythPriceForAsset(asset) {
|
|
|
241204
241354
|
pythStateDatum = void 0;
|
|
241205
241355
|
}
|
|
241206
241356
|
return {
|
|
241357
|
+
...livePrice,
|
|
241207
241358
|
feedConfig: {
|
|
241208
241359
|
pythFeedValHash: feedConfig.pythFeedValHash,
|
|
241209
241360
|
feedParams: feedConfig.params
|
|
241210
241361
|
},
|
|
241211
241362
|
pythState: pythStateDatum,
|
|
241212
|
-
note:
|
|
241363
|
+
note: `The price is the latest signed Pyth update served by the Indigo analytics API \u2014 the same payload the write tools embed on-chain. It is only valid on-chain until validUntil (${PYTH_MAX_DELAY_MS / 1e3}s after priceTimestamp); the on-chain Pyth state datum itself carries governance and trusted-signer configuration, not price values.`
|
|
241213
241364
|
};
|
|
241214
241365
|
}
|
|
241215
241366
|
var init_oracle_tools = __esm({
|
|
@@ -241223,6 +241374,7 @@ var init_oracle_tools = __esm({
|
|
|
241223
241374
|
init_sdk_config();
|
|
241224
241375
|
init_validators();
|
|
241225
241376
|
init_v3_finders();
|
|
241377
|
+
init_pyth();
|
|
241226
241378
|
init_lucid_provider();
|
|
241227
241379
|
}
|
|
241228
241380
|
});
|
|
@@ -252730,6 +252882,91 @@ var init_payment = __esm({
|
|
|
252730
252882
|
}
|
|
252731
252883
|
});
|
|
252732
252884
|
|
|
252885
|
+
// package.json
|
|
252886
|
+
var package_default2;
|
|
252887
|
+
var init_package = __esm({
|
|
252888
|
+
"package.json"() {
|
|
252889
|
+
package_default2 = {
|
|
252890
|
+
name: "@indigoprotocol/indigo-mcp",
|
|
252891
|
+
version: "0.4.0",
|
|
252892
|
+
type: "module",
|
|
252893
|
+
description: "MCP server for Indigo Protocol",
|
|
252894
|
+
main: "dist/index.js",
|
|
252895
|
+
types: "dist/index.d.ts",
|
|
252896
|
+
bin: {
|
|
252897
|
+
"indigo-mcp": "dist/index.js",
|
|
252898
|
+
"indigo-mcp-setup": "dist/cli/setup.js"
|
|
252899
|
+
},
|
|
252900
|
+
files: [
|
|
252901
|
+
"dist",
|
|
252902
|
+
"dist/*.wasm"
|
|
252903
|
+
],
|
|
252904
|
+
keywords: [
|
|
252905
|
+
"mcp",
|
|
252906
|
+
"indigo",
|
|
252907
|
+
"cardano",
|
|
252908
|
+
"defi",
|
|
252909
|
+
"ai-agent"
|
|
252910
|
+
],
|
|
252911
|
+
scripts: {
|
|
252912
|
+
prepublishOnly: "npm run build",
|
|
252913
|
+
build: "bash scripts/build.sh",
|
|
252914
|
+
"build:tsc": "tsc --project tsconfig.build.json",
|
|
252915
|
+
start: "node dist/index.js",
|
|
252916
|
+
dev: "tsx src/index.ts",
|
|
252917
|
+
typecheck: "tsc --noEmit",
|
|
252918
|
+
lint: "eslint",
|
|
252919
|
+
"lint:fix": "eslint --fix",
|
|
252920
|
+
format: 'prettier --write "src/**/*.{ts,js,json,md}"',
|
|
252921
|
+
"format:check": 'prettier --check "src/**/*.{ts,js,json,md}"',
|
|
252922
|
+
test: "vitest run",
|
|
252923
|
+
"test:watch": "vitest",
|
|
252924
|
+
"smithery:build": "bash scripts/smithery-build.sh",
|
|
252925
|
+
"smithery:publish": "bash scripts/smithery-build.sh && npx smithery mcp publish --name indigoprotocol/indigo-mcp --from-build .smithery/stdio"
|
|
252926
|
+
},
|
|
252927
|
+
engines: {
|
|
252928
|
+
node: ">=20"
|
|
252929
|
+
},
|
|
252930
|
+
repository: {
|
|
252931
|
+
type: "git",
|
|
252932
|
+
url: "https://github.com/IndigoProtocol/indigo-mcp"
|
|
252933
|
+
},
|
|
252934
|
+
author: "Indigo Protocol",
|
|
252935
|
+
license: "MIT",
|
|
252936
|
+
mcpName: "io.github.IndigoProtocol/indigo-mcp",
|
|
252937
|
+
publishConfig: {
|
|
252938
|
+
access: "public"
|
|
252939
|
+
},
|
|
252940
|
+
devDependencies: {
|
|
252941
|
+
"@3rd-eye-labs/cardano-offchain-common": "^1.2.0",
|
|
252942
|
+
"@indigo-labs/indigo-sdk": "^0.3.28",
|
|
252943
|
+
"@lucid-evolution/lucid": "^0.4.29",
|
|
252944
|
+
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
252945
|
+
"@qbtlabs/x402": "^0.5.0",
|
|
252946
|
+
"@types/node": "^24.3.1",
|
|
252947
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
252948
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
252949
|
+
axios: "^1.12.2",
|
|
252950
|
+
bech32: "^2.0.0",
|
|
252951
|
+
dotenv: "^17.3.1",
|
|
252952
|
+
esbuild: "^0.27.3",
|
|
252953
|
+
eslint: "^9.0.0",
|
|
252954
|
+
"patch-package": "^8.0.1",
|
|
252955
|
+
prettier: "^3.0.0",
|
|
252956
|
+
tsx: "^4.0.0",
|
|
252957
|
+
typescript: "^5.9.2",
|
|
252958
|
+
vitest: "^4.0.18",
|
|
252959
|
+
zod: "^3.25.76"
|
|
252960
|
+
},
|
|
252961
|
+
dependencies: {
|
|
252962
|
+
"libsodium-sumo": "^0.7.16",
|
|
252963
|
+
"libsodium-wrappers-sumo": "^0.7.16",
|
|
252964
|
+
undici: "^7.24.5"
|
|
252965
|
+
}
|
|
252966
|
+
};
|
|
252967
|
+
}
|
|
252968
|
+
});
|
|
252969
|
+
|
|
252733
252970
|
// src/server.ts
|
|
252734
252971
|
var server_exports = {};
|
|
252735
252972
|
__export(server_exports, {
|
|
@@ -252747,9 +252984,67 @@ function createServer() {
|
|
|
252747
252984
|
registerResources(server);
|
|
252748
252985
|
return server;
|
|
252749
252986
|
}
|
|
252750
|
-
async function
|
|
252987
|
+
async function readJsonBody(req) {
|
|
252988
|
+
const chunks2 = [];
|
|
252989
|
+
for await (const chunk3 of req) {
|
|
252990
|
+
chunks2.push(chunk3);
|
|
252991
|
+
}
|
|
252992
|
+
if (chunks2.length === 0) return void 0;
|
|
252993
|
+
return JSON.parse(Buffer.concat(chunks2).toString("utf8"));
|
|
252994
|
+
}
|
|
252995
|
+
function sendJsonRpcError(res, status, code, message) {
|
|
252996
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
252997
|
+
res.end(JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }));
|
|
252998
|
+
}
|
|
252999
|
+
async function startHttpServer(port2, host) {
|
|
252751
253000
|
process.stderr.write(`Indigo MCP starting HTTP server...
|
|
252752
253001
|
`);
|
|
253002
|
+
const transports = /* @__PURE__ */ new Map();
|
|
253003
|
+
async function handleMcpRequest(req, res) {
|
|
253004
|
+
let body;
|
|
253005
|
+
if (req.method === "POST") {
|
|
253006
|
+
try {
|
|
253007
|
+
body = await readJsonBody(req);
|
|
253008
|
+
} catch {
|
|
253009
|
+
sendJsonRpcError(res, 400, -32700, "Parse error: request body is not valid JSON");
|
|
253010
|
+
return;
|
|
253011
|
+
}
|
|
253012
|
+
}
|
|
253013
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
253014
|
+
const existing = typeof sessionId === "string" ? transports.get(sessionId) : void 0;
|
|
253015
|
+
if (existing) {
|
|
253016
|
+
await existing.handleRequest(req, res, body);
|
|
253017
|
+
return;
|
|
253018
|
+
}
|
|
253019
|
+
if (req.method !== "POST" || !isInitializeRequest(body)) {
|
|
253020
|
+
if (typeof sessionId === "string") {
|
|
253021
|
+
sendJsonRpcError(
|
|
253022
|
+
res,
|
|
253023
|
+
404,
|
|
253024
|
+
-32001,
|
|
253025
|
+
`Session not found: ${sessionId}. Send an initialize request to start a new session.`
|
|
253026
|
+
);
|
|
253027
|
+
} else {
|
|
253028
|
+
sendJsonRpcError(res, 400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
253029
|
+
}
|
|
253030
|
+
return;
|
|
253031
|
+
}
|
|
253032
|
+
const transport = new StreamableHTTPServerTransport({
|
|
253033
|
+
sessionIdGenerator: () => randomUUID(),
|
|
253034
|
+
onsessioninitialized: (id) => {
|
|
253035
|
+
transports.set(id, transport);
|
|
253036
|
+
},
|
|
253037
|
+
onsessionclosed: (id) => {
|
|
253038
|
+
transports.delete(id);
|
|
253039
|
+
}
|
|
253040
|
+
});
|
|
253041
|
+
transport.onclose = () => {
|
|
253042
|
+
if (transport.sessionId) transports.delete(transport.sessionId);
|
|
253043
|
+
};
|
|
253044
|
+
const server = createServer();
|
|
253045
|
+
await server.connect(transport);
|
|
253046
|
+
await transport.handleRequest(req, res, body);
|
|
253047
|
+
}
|
|
252753
253048
|
const httpServer = createHttpServer((req, res) => {
|
|
252754
253049
|
const url3 = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
|
252755
253050
|
if (url3.pathname === "/health") {
|
|
@@ -252758,27 +253053,22 @@ async function startHttpServer(port2) {
|
|
|
252758
253053
|
return;
|
|
252759
253054
|
}
|
|
252760
253055
|
if (url3.pathname === "/mcp") {
|
|
252761
|
-
|
|
252762
|
-
|
|
252763
|
-
|
|
252764
|
-
|
|
252765
|
-
|
|
252766
|
-
|
|
253056
|
+
handleMcpRequest(req, res).catch((error2) => {
|
|
253057
|
+
process.stderr.write(`Indigo MCP request error: ${error2}
|
|
253058
|
+
`);
|
|
253059
|
+
if (!res.headersSent) {
|
|
253060
|
+
sendJsonRpcError(res, 500, -32603, "Internal server error");
|
|
253061
|
+
} else {
|
|
253062
|
+
res.end();
|
|
253063
|
+
}
|
|
253064
|
+
});
|
|
252767
253065
|
return;
|
|
252768
253066
|
}
|
|
252769
253067
|
res.writeHead(404);
|
|
252770
253068
|
res.end("Not found");
|
|
252771
253069
|
});
|
|
252772
|
-
|
|
252773
|
-
|
|
252774
|
-
process.stderr.write(`Indigo MCP HTTP server listening on 0.0.0.0:${port2}
|
|
252775
|
-
`);
|
|
252776
|
-
const server = createServer();
|
|
252777
|
-
transport = new StreamableHTTPServerTransport({
|
|
252778
|
-
sessionIdGenerator: () => randomUUID()
|
|
252779
|
-
});
|
|
252780
|
-
await server.connect(transport);
|
|
252781
|
-
process.stderr.write(`Indigo MCP server ready
|
|
253070
|
+
httpServer.listen(port2, host, () => {
|
|
253071
|
+
process.stderr.write(`Indigo MCP HTTP server listening on ${host}:${port2}/mcp
|
|
252782
253072
|
`);
|
|
252783
253073
|
});
|
|
252784
253074
|
}
|
|
@@ -252790,8 +253080,9 @@ async function startStdioServer() {
|
|
|
252790
253080
|
async function main2() {
|
|
252791
253081
|
const mode = process.env.MCP_TRANSPORT ?? "stdio";
|
|
252792
253082
|
if (mode === "http") {
|
|
252793
|
-
const port2 = parseInt(process.env.PORT ?? "3000", 10);
|
|
252794
|
-
|
|
253083
|
+
const port2 = parseInt(process.env.PORT ?? process.env.MCP_PORT ?? "3000", 10);
|
|
253084
|
+
const host = process.env.HOST ?? "0.0.0.0";
|
|
253085
|
+
await startHttpServer(port2, host);
|
|
252795
253086
|
} else {
|
|
252796
253087
|
await startStdioServer();
|
|
252797
253088
|
}
|
|
@@ -252803,11 +253094,13 @@ var init_server3 = __esm({
|
|
|
252803
253094
|
init_mcp();
|
|
252804
253095
|
init_stdio2();
|
|
252805
253096
|
init_streamableHttp();
|
|
253097
|
+
init_types2();
|
|
252806
253098
|
init_tools();
|
|
252807
253099
|
init_resources();
|
|
252808
253100
|
init_payment();
|
|
253101
|
+
init_package();
|
|
252809
253102
|
SERVER_NAME = "indigo-mcp";
|
|
252810
|
-
SERVER_VERSION =
|
|
253103
|
+
SERVER_VERSION = package_default2.version;
|
|
252811
253104
|
main2().catch((error2) => {
|
|
252812
253105
|
process.stderr.write(`Indigo MCP error: ${error2}
|
|
252813
253106
|
`);
|