Skip to navigation

3. Add Skills and MCP

View as MarkdownOpen in Claude

Extend the Hermes variant from 2. Switch Harnesses with a code-review skill and a local Model Context Protocol (MCP) tool. This third quickstart reuses the model and configuration in first_agent.py, the Hermes environment with MCP support, and HERMES_ADAPTER_PYTHON. Keep your application’s .venv active.

1

Add a Review Skill

Create skills/review/SKILL.md beside first_agent.py with the following content:

---
name: review
description: Use when reviewing a Python function for correctness.
---
Report findings under the heading "Review checks". Include the triggering
input, what fails, and a suggested correction. When the check_average MCP
tool is available, use it with an empty list and with [2, 4, 6] to check the
example's edge case and ordinary case. Distinguish tool results from your
own reasoning.

The skill supplies review instructions. The MCP server in the next step supplies an executable tool; these are separate capabilities.

2

Create a Local MCP Tool

The Hermes environment created in step two includes MCP 2.3 through its mcp extra. This example uses that version’s MCPServer API. Save this complete server as review_tools.py beside first_agent.py. It computes the example’s average without network access and records each tool call in a local JSON Lines file:

import json
from pathlib import Path
from mcp.server.mcpserver import MCPServer
server = MCPServer("review-tools", log_level="ERROR")
call_log = Path(__file__).with_name("mcp-tool-calls.jsonl")
@server.tool()
def check_average(values: list[float]) -> dict:
"""Check the average calculation, including the empty-list edge case."""
if values:
result = {"average": sum(values) / len(values), "error": None}
else:
result = {"average": None, "error": "division_by_zero"}
with call_log.open("a", encoding="utf-8") as handle:
handle.write(json.dumps({"values": values, **result}) + "\n")
return result
if __name__ == "__main__":
server.run(transport="stdio")

Do not start the server manually. The harness launches it through stdio when the agent starts. Keep protocol output on stdout; the example writes call evidence to the file instead.

3

Run the Extended Agent

Save this complete example as extended_agent.py beside the other files. It selects the already-installed Hermes adapter and uses the same Hermes interpreter for the adapter and MCP server:

import asyncio
import os
from pathlib import Path
from first_agent import config
from nemo_fabric import Fabric, HarnessConfig
app_dir = Path(__file__).resolve().parent
hermes_python = os.environ["HERMES_ADAPTER_PYTHON"]
variant = config.model_copy(deep=True)
variant.harness = HarnessConfig(adapter_id="nvidia.fabric.hermes")
variant.tools = None
variant.add_skill_path(app_dir / "skills" / "review")
variant.add_mcp_server(
"review-tools",
transport="stdio",
url=hermes_python,
args=[str(app_dir / "review_tools.py")],
exposure="harness_native",
)
async def main():
original_python = os.environ.get("ADAPTER_PYTHON")
os.environ["ADAPTER_PYTHON"] = hermes_python
try:
result = await Fabric().run(
variant,
input=(
"Use the review skill to review this Python function. "
"Call the check_average MCP tool with [] and [2, 4, 6], "
"then explain the bug and a correction.\n\n"
"def average(values):\n"
" return sum(values) / len(values)\n"
),
)
print("Status:", result.status)
if result.status == "succeeded":
print(result.output.response)
else:
print("Error:", result.error)
finally:
if original_python is None:
os.environ.pop("ADAPTER_PYTHON", None)
else:
os.environ["ADAPTER_PYTHON"] = original_python
if __name__ == "__main__":
asyncio.run(main())

From the application directory, run:

python extended_agent.py

The environment-variable selection is sequential, as in step two. Production launchers should establish consistent execution environments instead of changing process-wide variables around concurrent starts.

4

Check the Review and Tool Calls

Look for status succeeded and a review that identifies the empty-list division error under the skill’s requested heading. Inspect mcp-tool-calls.jsonl for these records; ordering and repeat calls can vary:

{"values": [], "average": null, "error": "division_by_zero"}
{"values": [2.0, 4.0, 6.0], "average": 4.0, "error": null}

The log proves the local tool ran. A successful agent response alone does not prove tool use or skill loading; the requested heading is an observable sign that the skill’s instructions influenced the review. For a repeat run, distinguish newly appended records from earlier calls. If startup or invocation fails, follow Troubleshooting. If the run succeeds without the required checks, inspect the response and tool log before treating the task as complete.

Next Steps

Continue to 4. Run in OpenShell (Optional) for the source-checkout sandbox example. Refer to Tools, Skills, and MCP for authentication, tool policy, and adapter differences, or Plan and Diagnose to inspect configuration before execution.