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
versionCompiles 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 deploymentCan also be used for simulation or code validation
Tool Name: solc.compile
solc.compile
Request
{
"tool": "solc.compile",
"args": {
"source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\ncontract Hello { string public greet = 'hi'; }"
}
}
Response
{
"abi": [ { "inputs": [], "name": "greet", "outputs": [{ "type": "string" }], ... } ],
"bytecode": "0x608060405234...",
"compilerVersion": "0.8.19",
"warnings": [],
"errors": []
}
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:
git clone https://github.com/pilso-os/mcp-servers
cd mcp-servers/solc-mcp
npm install
npm start
Default port: 3050
Update your pilso.config.json
:
"tools": [
"http://localhost:3050"
]
Compiler Version Resolution
By default, solc-mcp
:
Parses
pragma
directives to match the required versionFalls back to
solc@latest
if unspecifiedUses
solc-js
via npm package or binary cache
Optional flag:
"version": "0.8.17"
You can force a version via explicit parameter in the request.
Output Format
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
npx pilso call \
--tool solc.compile \
--args '{"source": "pragma solidity ^0.8.19; contract A { uint x; }"}'
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
, andreviewer
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
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