solc-mcp: Contract Compile

The solc-mcp module allows agents to securely compile Solidity smart contracts without relying on third-party explorers or IDEs.

It wraps the official solc-js compiler in a controlled MCP server that can:

  • Compile a given Solidity source string

  • Return the ABI, bytecode, and metadata

  • Detect syntax and compiler errors

  • Support version pinning (via pragma or param)

This lets your agents prepare smart contracts for deployment or audit — completely from natural language prompts.


What It Does

  • Receives raw Solidity contract source

  • Resolves the appropriate solc version

  • Compiles source with safe defaults

  • Returns ABI, bytecode, errors (if any)

This server does not deploy contracts — it only compiles them.


Architecture

Agent → solc-mcp → solc-js → Compiled Output → signer (optional)
  • Used before passing bytecode to metamask-mcp for deployment

  • Can also be used for simulation or code validation


Tool Name: solc.compile

Request

Response

If there are compile-time issues, the errors array will be populated with structured messages from the compiler.


Server Setup

To run solc-mcp locally:

Default port: 3050

Update your pilso.config.json:


Compiler Version Resolution

By default, solc-mcp:

  • Parses pragma directives to match the required version

  • Falls back to solc@latest if unspecified

  • Uses solc-js via npm package or binary cache

Optional flag:

You can force a version via explicit parameter in the request.


Output Format

Field
Description

abi

Standard ABI JSON

bytecode

Hex-encoded deployable bytecode

compilerVersion

Actual compiler version used

warnings

Non-blocking issues

errors

Critical blocking issues (if any)

All outputs are structured to be consumed directly by metamask-mcp or logged for agent interpretation.


Test Call Locally


Safety Notes

  • Compilation is fully isolated — no contract is ever deployed from this tool

  • It can be safely exposed to most agent roles, including developer, auditor, and reviewer

  • Avoid giving compile + sign access to general-purpose roles unless tightly scoped


Future Additions

  • Support for source map + opcode output

  • AI-assisted static analysis hooks

  • Bytecode diff tools for version comparison


✅ Summary

Property
Value

Tool name

solc.compile

Port

3050 (default)

Signature

No — compiles only

Chain Support

EVM-based chains only

Depends on

solc-js, pragma resolution

The solc-mcp module gives your PILSO agent the power to understand, compile, and prepare contracts — safely and reproducibly, from source code to deployable bytecode.

Last updated