Skip to main content
Glama
jim-agent

NEAR Contract Deployer MCP Server

by jim-agent

NEAR Contract Deployer MCP Server

An MCP (Model Context Protocol) server that enables AI assistants like Claude to deploy, initialize, and upgrade NEAR smart contracts.

Features

  • deploy_contract: Deploy WASM smart contracts to NEAR accounts

  • initialize_contract: Call initialization methods after deployment

  • upgrade_contract: Upgrade existing contracts with new code

  • get_deployment_status: Check if an account has a contract deployed

  • estimate_deployment_cost: Calculate storage costs before deploying

Related MCP server: Solana Web3.js MCP Server

Installation

npm install
npm run build

Configuration

Credentials

The server looks for NEAR credentials in these locations (in order):

  1. ~/.near-credentials/{network}/{account_id}.json

  2. ~/.near/credentials/{network}/{account_id}.json

  3. ./.near-credentials/{network}/{account_id}.json

You can also provide credentials directly via the private_key parameter.

Generate Credentials

# For testnet
near login --networkId testnet

# For mainnet  
near login --networkId mainnet

Usage with Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "near-deploy": {
      "command": "node",
      "args": ["/path/to/mcp-near-deploy/dist/index.js"]
    }
  }
}

Example Conversations

Deploying a New Contract

User: Deploy my contract to testnet

Claude: I'll help you deploy your contract. First, let me estimate the costs.

Tool: estimate_deployment_cost
Args: {"wasm_path": "./target/wasm32-unknown-unknown/release/my_contract.wasm"}

πŸ’° DEPLOYMENT COST ESTIMATE

πŸ“Š Cost Breakdown:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  WASM Size:       156.32 KB (160,072 bytes)
  Storage Cost:    1.600720 NEAR
  Estimated Gas:   11 TGas
  Total Estimate:  ~1.65 NEAR

πŸ’‘ Recommendation:
   βœ… Contract size is reasonable. Deployment should proceed smoothly.

Now let me deploy it:

Tool: deploy_contract
Args: {
  "account_id": "mycontract.testnet",
  "wasm_path": "./target/wasm32-unknown-unknown/release/my_contract.wasm",
  "network": "testnet"
}

βœ… CONTRACT DEPLOYED SUCCESSFULLY

πŸ“‹ Deployment Details:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Contract ID:     mycontract.testnet
  Network:         testnet
  WASM Size:       156.32 KB
  Storage Cost:    1.600720 NEAR
  Transaction:     7abc123...

πŸ”— Explorer: https://explorer.testnet.near.org/transactions/7abc123...

πŸ“ Next Steps:
  1. Initialize the contract using initialize_contract()
  2. Verify deployment with get_deployment_status()

Initializing a Contract

User: Initialize the contract with owner set to my account

Claude: I'll initialize your contract with the specified owner:

Tool: initialize_contract
Args: {
  "contract_id": "mycontract.testnet",
  "method_name": "new",
  "args": {"owner_id": "yourname.testnet"},
  "network": "testnet"
}

βœ… CONTRACT INITIALIZED SUCCESSFULLY

πŸ“‹ Initialization Details:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Contract ID:     mycontract.testnet
  Method:          new
  Arguments:       {"owner_id": "yourname.testnet"}
  Transaction:     8def456...

πŸ”— Explorer: https://explorer.testnet.near.org/transactions/8def456...

✨ The contract is now ready to use!

Checking Deployment Status

User: Is there a contract on wrap.near?

Claude: Let me check the deployment status:

Tool: get_deployment_status
Args: {"account_id": "wrap.near", "network": "mainnet"}

βœ… CONTRACT IS DEPLOYED

πŸ“‹ Deployment Status:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Contract ID:     wrap.near
  Network:         mainnet
  Code Hash:       4Fh7SHqU...
  Storage Used:    3,456,789 bytes
  Storage Cost:    34.567890 NEAR
  Balance:         1,234.567890 NEAR

πŸ”— Explorer: https://explorer.near.org/accounts/wrap.near

✨ Contract is ready to interact with!

Upgrading a Contract

User: Upgrade my contract with the new version

Claude: I'll upgrade your contract with the new WASM and run the migration:

Tool: upgrade_contract
Args: {
  "contract_id": "mycontract.testnet",
  "wasm_path": "./target/wasm32-unknown-unknown/release/my_contract_v2.wasm",
  "migrate_method": "migrate",
  "network": "testnet"
}

βœ… CONTRACT UPGRADED SUCCESSFULLY

πŸ“‹ Upgrade Details:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Contract ID:     mycontract.testnet
  Network:         testnet
  New WASM Size:   162.45 KB
  Storage Cost:    1.624500 NEAR
  Deploy TX:       9ghi789...
  Migration TX:    0jkl012...

πŸ”— Explorer: https://explorer.testnet.near.org/transactions/9ghi789...

✨ Migration completed successfully!

Cost Estimation

User: How much will it cost to deploy a 500KB contract?

Claude: Let me calculate the deployment cost:

Tool: estimate_deployment_cost
Args: {"wasm_size_bytes": 512000}

πŸ’° DEPLOYMENT COST ESTIMATE

πŸ“Š Cost Breakdown:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  WASM Size:       500.00 KB (512,000 bytes)
  
  Storage Cost:    5.120000 NEAR
                   (5120000000000000000000000 yoctoNEAR)
  
  Estimated Gas:   15 TGas
  Gas Cost:        ~0.001500 NEAR
  
  ─────────────────────────────────
  Total Estimate:  5.121500 NEAR

πŸ’‘ Recommendation:
   πŸ’Έ Storage cost is significant. Ensure account has sufficient NEAR balance.

πŸ“ Notes:
   β€’ Storage costs are exact (1 byte = 0.00001 NEAR)
   β€’ Gas costs may vary based on network conditions
   β€’ Add ~10% buffer for safety

API Reference

deploy_contract

Deploy a WASM smart contract to a NEAR account.

Parameter

Type

Required

Description

account_id

string

βœ…

NEAR account to deploy to

wasm_path

string

❌*

Path to WASM file

wasm_base64

string

❌*

Base64-encoded WASM

network

string

❌

"mainnet" or "testnet" (default: testnet)

private_key

string

❌

Signing key (ed25519:xxx format)

*Either wasm_path or wasm_base64 required

initialize_contract

Call an initialization method on a deployed contract.

Parameter

Type

Required

Description

contract_id

string

βœ…

Contract account ID

method_name

string

βœ…

Init method name

args

object

❌

Method arguments

deposit

string

❌

NEAR to attach (e.g., "1.5")

gas

string

❌

Gas limit in TGas (default: 100)

network

string

❌

"mainnet" or "testnet"

private_key

string

❌

Signing key

upgrade_contract

Upgrade an existing contract with new WASM code.

Parameter

Type

Required

Description

contract_id

string

βœ…

Contract to upgrade

wasm_path

string

❌*

Path to new WASM file

wasm_base64

string

❌*

Base64-encoded new WASM

migrate_method

string

❌

Migration method to call

migrate_args

object

❌

Migration arguments

network

string

❌

"mainnet" or "testnet"

private_key

string

❌

Signing key

get_deployment_status

Check if an account has a contract deployed.

Parameter

Type

Required

Description

account_id

string

βœ…

Account to check

network

string

❌

"mainnet" or "testnet" (default: mainnet)

estimate_deployment_cost

Calculate storage costs for deployment.

Parameter

Type

Required

Description

wasm_path

string

❌*

Path to WASM file

wasm_base64

string

❌*

Base64-encoded WASM

wasm_size_bytes

number

❌*

Direct size in bytes

*At least one required

Networks

  • Mainnet: Production network (mainnet)

  • Testnet: Development network (testnet)

Default network is testnet for safety.

Security Notes

  • Never share or commit private keys

  • Use environment variables or credential files for keys

  • Test on testnet before mainnet deployments

  • Review contract code before deploying

License

MIT

Available Tools

5 tools
deploy_contractB

Deploy a WebAssembly (WASM) smart contract to a NEAR account. Requires the deployer account to have sufficient balance for storage costs.

ParametersJSON Schema
NameRequiredDescriptionDefault
networkNoNEAR network to deploy to (default: testnet)
wasm_pathNoPath to the compiled WASM file
account_idYesThe NEAR account ID to deploy the contract to (e.g., "mycontract.testnet")
private_keyNoOptional: Private key for signing (ed25519:xxx format). If not provided, uses ~/.near-credentials/
wasm_base64NoAlternative: Base64-encoded WASM bytes (use instead of wasm_path)

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of disclosing behavior. It mentions the storage cost requirement but fails to disclose that deploying may overwrite existing contract code, requires signing privileges, or produces transaction-related side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the action, and contains no filler. It delivers the core purpose and one key requirement without unnecessary verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a deployment tool with five parameters and no output schema, the description is too minimal. It does not explain the relationship between wasm_path and wasm_base64, whether the contract initialization is part of this step or separate, or what the return value is, leaving the agent under-informed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides 100% description coverage for all five parameters, including alternatives like wasm_path and wasm_base64. The description adds no additional parameter meaning, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: deploying a WASM smart contract to a NEAR account. It uses a specific verb and resource, and the focus on deployment distinguishes it from sibling tools like upgrade_contract and initialize_contract.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The only additional note about storage cost balance is a prerequisite rather than usage direction, and there is no mention of exclusions or scenarios favoring other sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

estimate_deployment_costA

Calculate the storage cost for deploying a WASM contract before actually deploying.

ParametersJSON Schema
NameRequiredDescriptionDefault
wasm_pathNoPath to the compiled WASM file
wasm_base64NoAlternative: Base64-encoded WASM bytes
wasm_size_bytesNoAlternative: Provide WASM size directly in bytes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden of behavioral disclosure. It implies that the tool does not deploy ('before actually deploying') but does not explicitly state it is read-only or has no side effects. It also doesn't mention any external dependencies or computation specifics, leaving some transparency gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that immediately states the purpose. Every word earns its place, with no filler or redundancy. It is concise while still conveying the core functionality and timing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has a simple interface (3 alternative params, no output schema). The description effectively communicates that it estimates deployment cost, which is the main purpose. However, it does not mention what the return value looks like (e.g., numeric cost in tokens/currency), which would be useful. Given the low complexity, this is a minor omission, and the description is otherwise complete for guiding selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already provides 100% coverage with descriptions for each parameter, including noting they are alternatives. The tool description adds no additional parameter semantics beyond the schema, so it does not go above the baseline. It does not clarify when to prefer wasm_path over wasm_base64, but the schema's 'Alternative' notes help.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the verb 'Calculate' and the resource 'storage cost for deploying a WASM contract'. It distinguishes itself from sibling tools like deploy_contract and initialize_contract by focusing on cost estimation rather than actual deployment.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'before actually deploying' provides a clear temporal context for when to use the tool. While it doesn't explicitly name alternatives, the sibling list includes deployment-related tools, making it obvious that this is a pre-deployment step. It could be more explicit by saying 'use this instead of deploy_contract to estimate costs without committing', but the current wording is adequate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_deployment_statusA

Check if a NEAR account has a smart contract deployed and get deployment details.

ParametersJSON Schema
NameRequiredDescriptionDefault
networkNoNEAR network to query (default: mainnet)
account_idYesThe NEAR account ID to check

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of disclosing behavior. It implies a non-destructive check but never explicitly states that it does not modify anything or what exactly 'deployment details' includes. This lack of explicit safety and output context is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with the main verb first and no filler. It earns its place by conveying both purpose and scope in minimal words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema or annotations, the description should clarify what 'deployment details' returns and whether there are any side effects. It does neither, leaving the agent without adequate context for a correct invocation or result interpretation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already documents both parameters with descriptions, giving 100% coverage, so the baseline is 3. The description adds no extra meaning about parameters (e.g., network default or accepted formats), relying entirely on the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Check if') and identifies the resource (NEAR account), making the action and scope immediately clear. It distinguishes itself from sibling deployment tools by focusing on querying status rather than modifying, which is a distinct purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly implies a read-only status query, which contrasts with the mutation-focused sibling tools like deploy_contract and upgrade_contract. However, it does not explicitly state when to prefer this tool over alternatives or mention any exclusions, so it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

initialize_contractA

Call an initialization method on a deployed contract. Most contracts require this after deployment.

ParametersJSON Schema
NameRequiredDescriptionDefault
gasNoOptional: Gas limit in TGas (default: 100)
argsNoInitialization arguments as JSON object
depositNoOptional: NEAR amount to attach (in NEAR, e.g., "1.5")
networkNoNEAR network (default: testnet)
contract_idYesThe NEAR account ID of the deployed contract
method_nameYesName of the init method (commonly "new" or "init")
private_keyNoOptional: Private key for signing

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It only states that an init method is called; it does not mention that this is a state-changing transaction, that private_key is needed for signing, potential side effects like double-initialization errors, or whether it is irreversible. The description adds minimal behavioral context beyond what the schema already lists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: two short sentences that immediately state the action and the typical usage context. Every word earns its place, and the key information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite good schema coverage, the tool has 7 parameters, no output schema, and no annotations. The description is too terse to cover important contextual aspects like return values, failure modes (e.g., 'method already initialized'), network defaults, or the difference between 'new' and 'init' methods. As a state-changing blockchain operation, more context is needed for safe autonomous invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides 100% coverage for all 7 parameters, each with detailed descriptions. The description itself adds no parameter-specific guidance, so the baseline score of 3 is appropriate since the schema already documents the parameters thoroughly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Call') and resource ('initialization method on a deployed contract'), clearly distinguishing it from sibling tools like deploy_contract or upgrade_contract. The added context 'Most contracts require this after deployment' reinforces the tool's specific role in the contract lifecycle.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'Most contracts require this after deployment' implies the tool is used post-deployment, which helps orient the agent. However, it does not explicitly mention when not to use it or name alternatives, though sibling tool names provide implicit differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

upgrade_contractA

Upgrade an existing contract with new WASM code. The contract must be owned by the signer.

ParametersJSON Schema
NameRequiredDescriptionDefault
networkNoNEAR network (default: testnet)
wasm_pathNoPath to the new compiled WASM file
contract_idYesThe NEAR account ID of the contract to upgrade
private_keyNoOptional: Private key for signing
wasm_base64NoAlternative: Base64-encoded new WASM bytes
migrate_argsNoOptional: Arguments for migration method
migrate_methodNoOptional: Migration method to call after upgrade (e.g., "migrate")

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the burden of behavioral disclosure. It discloses the ownership requirement ('must be owned by the signer') and implies code replacement, but omits details on irreversibility, migration invocation, state persistence, or potential failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences with no redundant phrasing. The purpose is front-loaded, and the ownership constraint is stated efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex operation with 7 parameters and no output schema, this description is too minimal. It lacks guidance on when to use wasm_path versus wasm_base64, how migration methods are invoked, and what outcome the agent should expect after calling the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so each parameter is already documented. The description only loosely references WASM code and ownership, adding little beyond the schema. Baseline 3 is appropriate because the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action ('Upgrade an existing contract') and its resource ('with new WASM code'), which distinguishes it from sibling tools like deploy_contract targeting new contracts. The phrase 'existing contract' reinforces the intended use case.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context that this tool is for existing contracts and includes an ownership prerequisite, but it does not explicitly contrast with deploy_contract or mention when migration arguments are relevant. No direct exclusions or alternative names are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.9/5.0
Disambiguation5/5

Each tool targets a distinct phase in the contract lifecycle: deploy creates, initialize configures, upgrade replaces, status checks, and cost estimates. There is no overlap or ambiguity between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (deploy_contract, initialize_contract, upgrade_contract, get_deployment_status, estimate_deployment_cost). The pattern is uniform and predictable.

Tool Count5/5

With 5 tools, the server is well-scoped for its purpose of managing NEAR contract deployments. Each tool is necessary and there is no redundancy or bloat.

Completeness5/5

The server covers the full deployment lifecycle: estimation, deployment, initialization, upgrading, and status checking. There are no obvious gaps for its stated purpose, as contract interaction beyond deployment is out of scope.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jim-agent/mcp-near-deploy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server