midnight-mcp 0.1.4 → 0.1.6
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.
|
@@ -147,7 +147,9 @@ const EXAMPLES = [
|
|
|
147
147
|
* Resolve repository name alias to owner/repo
|
|
148
148
|
*/
|
|
149
149
|
function resolveRepo(repoName) {
|
|
150
|
-
|
|
150
|
+
// Default to compact if not provided
|
|
151
|
+
const name = repoName || "compact";
|
|
152
|
+
const normalized = name.toLowerCase().replace(/^midnightntwrk\//, "");
|
|
151
153
|
const alias = REPO_ALIASES[normalized];
|
|
152
154
|
if (alias)
|
|
153
155
|
return alias;
|
|
@@ -158,8 +160,8 @@ function resolveRepo(repoName) {
|
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
// Assume it's a full org/repo name
|
|
161
|
-
if (
|
|
162
|
-
const [owner, repo] =
|
|
163
|
+
if (name.includes("/")) {
|
|
164
|
+
const [owner, repo] = name.split("/");
|
|
163
165
|
return { owner, repo };
|
|
164
166
|
}
|
|
165
167
|
return null;
|
|
@@ -278,7 +280,8 @@ export async function getLatestUpdates(input) {
|
|
|
278
280
|
export async function getVersionInfo(input) {
|
|
279
281
|
logger.debug("Getting version info", input);
|
|
280
282
|
// Special handling for "midnight-examples" - redirect to listing examples
|
|
281
|
-
const
|
|
283
|
+
const repoName = input.repo || "compact";
|
|
284
|
+
const normalizedRepo = repoName.toLowerCase();
|
|
282
285
|
if (normalizedRepo === "midnight-examples" || normalizedRepo === "examples") {
|
|
283
286
|
const exampleRepos = ["example-counter", "example-bboard", "example-dex"];
|
|
284
287
|
const versions = await Promise.all(exampleRepos.map(async (repoName) => {
|
|
@@ -727,6 +727,167 @@ export function useWallet() {
|
|
|
727
727
|
3. Store connection state in context
|
|
728
728
|
4. Provide clear loading/error feedback
|
|
729
729
|
5. Test with Midnight Lace extension
|
|
730
|
+
`,
|
|
731
|
+
// Common Errors Reference - VERIFIED from official Midnight documentation
|
|
732
|
+
"midnight://docs/common-errors": `# Common Midnight Errors & Solutions
|
|
733
|
+
|
|
734
|
+
Verified error messages from official Midnight documentation.
|
|
735
|
+
|
|
736
|
+
## Version Mismatch Errors
|
|
737
|
+
|
|
738
|
+
**Source:** [Fix version mismatch errors guide](https://docs.midnight.network/how-to/fix-version-mismatches)
|
|
739
|
+
|
|
740
|
+
Version mismatches occur when Midnight components are out of sync:
|
|
741
|
+
- Compact compiler
|
|
742
|
+
- Runtime libraries (@midnight-ntwrk/compact-runtime, @midnight-ntwrk/ledger)
|
|
743
|
+
- Proof server
|
|
744
|
+
- Indexer
|
|
745
|
+
|
|
746
|
+
### "Version mismatch" / CompactError
|
|
747
|
+
\`\`\`javascript
|
|
748
|
+
// The runtime checks version compatibility on startup
|
|
749
|
+
throw new __compactRuntime.CompactError(\`Version mismatch...\`);
|
|
750
|
+
\`\`\`
|
|
751
|
+
|
|
752
|
+
**Fix:** Check versions and update all components together:
|
|
753
|
+
\`\`\`bash
|
|
754
|
+
# Check your versions
|
|
755
|
+
compact --version
|
|
756
|
+
npm list @midnight-ntwrk/compact-runtime
|
|
757
|
+
npm list @midnight-ntwrk/ledger
|
|
758
|
+
|
|
759
|
+
# Consult the compatibility matrix
|
|
760
|
+
# https://docs.midnight.network/relnotes/support-matrix
|
|
761
|
+
\`\`\`
|
|
762
|
+
|
|
763
|
+
## Compact Compiler Errors
|
|
764
|
+
|
|
765
|
+
### "invalid context for a ledger ADT type"
|
|
766
|
+
**Source:** Compact 0.15/0.23 release notes
|
|
767
|
+
|
|
768
|
+
Ledger ADT types (Counter, Map, etc.) cannot be used as Compact types in casts.
|
|
769
|
+
|
|
770
|
+
\`\`\`compact
|
|
771
|
+
// ❌ Wrong - casting to ledger ADT type
|
|
772
|
+
const x = value as Counter; // Error!
|
|
773
|
+
|
|
774
|
+
// ✅ Correct - use the ledger field directly
|
|
775
|
+
ledger.counter.increment(1);
|
|
776
|
+
\`\`\`
|
|
777
|
+
|
|
778
|
+
### "static type error" - argument count/type mismatch
|
|
779
|
+
**Source:** Compact runtime type checks
|
|
780
|
+
|
|
781
|
+
\`\`\`javascript
|
|
782
|
+
// Runtime validates argument counts
|
|
783
|
+
if (args_1.length !== 2)
|
|
784
|
+
throw new __compactRuntime.CompactError(
|
|
785
|
+
\`post: expected 2 arguments, received \${args_1.length}\`
|
|
786
|
+
);
|
|
787
|
+
\`\`\`
|
|
788
|
+
|
|
789
|
+
**Fix:** Ensure TypeScript calls match circuit signatures exactly.
|
|
790
|
+
|
|
791
|
+
### assert() failures
|
|
792
|
+
**Source:** [Compact language reference](https://docs.midnight.network/develop/reference/compact/lang-ref)
|
|
793
|
+
|
|
794
|
+
\`\`\`compact
|
|
795
|
+
// Assert syntax (Compact 0.16+)
|
|
796
|
+
assert(condition, "error message");
|
|
797
|
+
|
|
798
|
+
// Example from bboard tutorial
|
|
799
|
+
assert(ledger.state == State.VACANT, "Attempted to post to an occupied board");
|
|
800
|
+
\`\`\`
|
|
801
|
+
|
|
802
|
+
**Note:** If assertion fails, the transaction fails without reaching the chain.
|
|
803
|
+
|
|
804
|
+
## TypeScript SDK Errors
|
|
805
|
+
|
|
806
|
+
### ContractTypeError
|
|
807
|
+
**Source:** @midnight-ntwrk/midnight-js-contracts
|
|
808
|
+
|
|
809
|
+
Thrown when there's a contract type mismatch between the given contract type
|
|
810
|
+
and the initial state deployed at a contract address.
|
|
811
|
+
|
|
812
|
+
\`\`\`typescript
|
|
813
|
+
// Typically thrown by findDeployedContract()
|
|
814
|
+
try {
|
|
815
|
+
const contract = await findDeployedContract(provider, address, MyContract);
|
|
816
|
+
} catch (e) {
|
|
817
|
+
if (e instanceof ContractTypeError) {
|
|
818
|
+
// The contract at this address is a different type
|
|
819
|
+
console.error('Contract type mismatch:', e.circuitIds);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
\`\`\`
|
|
823
|
+
|
|
824
|
+
### type_error() - Runtime type errors
|
|
825
|
+
**Source:** @midnight-ntwrk/compact-runtime
|
|
826
|
+
|
|
827
|
+
Internal function for type errors with parameters: who, what, where, type, value.
|
|
828
|
+
|
|
829
|
+
## DApp Connector Errors
|
|
830
|
+
|
|
831
|
+
**Source:** @midnight-ntwrk/dapp-connector-api ErrorCodes
|
|
832
|
+
|
|
833
|
+
\`\`\`typescript
|
|
834
|
+
import { ErrorCodes } from '@midnight-ntwrk/dapp-connector-api';
|
|
835
|
+
|
|
836
|
+
// ErrorCodes.Rejected - User rejected the request
|
|
837
|
+
// ErrorCodes.InvalidRequest - Malformed transaction or request
|
|
838
|
+
// ErrorCodes.InternalError - DApp connector couldn't process request
|
|
839
|
+
|
|
840
|
+
try {
|
|
841
|
+
const api = await window.midnight.mnLace.enable();
|
|
842
|
+
} catch (error) {
|
|
843
|
+
if (error.code === ErrorCodes.Rejected) {
|
|
844
|
+
console.log('User rejected wallet connection');
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
\`\`\`
|
|
848
|
+
|
|
849
|
+
## Node.js Environment Errors
|
|
850
|
+
|
|
851
|
+
### ERR_UNSUPPORTED_DIR_IMPORT
|
|
852
|
+
**Source:** [BBoard tutorial troubleshooting](https://docs.midnight.network/develop/tutorial/3-creating/bboard-dapp)
|
|
853
|
+
|
|
854
|
+
Occurs due to environment caching after modifying shell config or changing Node versions.
|
|
855
|
+
|
|
856
|
+
**Fix:**
|
|
857
|
+
\`\`\`bash
|
|
858
|
+
# 1. Open a NEW terminal window (don't just source ~/.zshrc)
|
|
859
|
+
# 2. Verify Node version
|
|
860
|
+
nvm use 18
|
|
861
|
+
|
|
862
|
+
# 3. Clear cached modules
|
|
863
|
+
rm -rf node_modules/.cache
|
|
864
|
+
\`\`\`
|
|
865
|
+
|
|
866
|
+
## Transaction Errors
|
|
867
|
+
|
|
868
|
+
### INSUFFICIENT_FUNDS / Not enough tDUST
|
|
869
|
+
**Source:** Midnight documentation examples
|
|
870
|
+
|
|
871
|
+
\`\`\`typescript
|
|
872
|
+
try {
|
|
873
|
+
const result = await sdk.sendTransaction(options);
|
|
874
|
+
} catch (error) {
|
|
875
|
+
if (error.code === 'INSUFFICIENT_FUNDS') {
|
|
876
|
+
console.error('Not enough tDUST in wallet');
|
|
877
|
+
// Direct user to testnet faucet
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
\`\`\`
|
|
881
|
+
|
|
882
|
+
## Debugging Resources
|
|
883
|
+
|
|
884
|
+
1. **Compatibility Matrix:** [/relnotes/support-matrix](https://docs.midnight.network/relnotes/support-matrix)
|
|
885
|
+
2. **Discord:** #developer-support channel
|
|
886
|
+
3. **Recompile after updates:**
|
|
887
|
+
\`\`\`bash
|
|
888
|
+
rm -rf contract/*.cjs contract/*.prover contract/*.verifier
|
|
889
|
+
compact compile src/contract.compact contract/
|
|
890
|
+
\`\`\`
|
|
730
891
|
`,
|
|
731
892
|
};
|
|
732
893
|
//# sourceMappingURL=docs-content.js.map
|
package/dist/resources/docs.js
CHANGED
|
@@ -58,6 +58,12 @@ export const documentationResources = [
|
|
|
58
58
|
description: "DApp Connector API for Midnight Lace wallet - React hooks, TypeScript types",
|
|
59
59
|
mimeType: "text/markdown",
|
|
60
60
|
},
|
|
61
|
+
{
|
|
62
|
+
uri: "midnight://docs/common-errors",
|
|
63
|
+
name: "Common Errors & Solutions",
|
|
64
|
+
description: "Troubleshooting guide: compiler errors, SDK errors, deployment issues with fixes",
|
|
65
|
+
mimeType: "text/markdown",
|
|
66
|
+
},
|
|
61
67
|
];
|
|
62
68
|
/**
|
|
63
69
|
* Get documentation content by URI
|
package/dist/server.js
CHANGED
|
@@ -7,10 +7,10 @@ import { allTools } from "./tools/index.js";
|
|
|
7
7
|
import { allResources, getDocumentation, getCode, getSchema, } from "./resources/index.js";
|
|
8
8
|
import { promptDefinitions, generatePrompt } from "./prompts/index.js";
|
|
9
9
|
import { registerSamplingCallback } from "./services/index.js";
|
|
10
|
-
// Server information
|
|
10
|
+
// Server information - version should match package.json
|
|
11
11
|
const SERVER_INFO = {
|
|
12
12
|
name: "midnight-mcp",
|
|
13
|
-
version: "1.
|
|
13
|
+
version: "0.1.4",
|
|
14
14
|
description: "MCP Server for Midnight Blockchain Development",
|
|
15
15
|
};
|
|
16
16
|
// Resource subscriptions tracking
|