ai-mcp-demo.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
from mcp.server.fastmcp import FastMCP
import tools
mcp = FastMCP("host info mcp")
mcp.add_tool(tools.get_host_info)
@mcp.tool()
def foo():
return ""
def main():
mcp.run("stdio") # sse
if __name__ == "__main__":
main()
import platform
import psutil
import subprocess
import json
def get_host_info() -> str:
"""get host information
Returns:
str: the host information in JSON string
"""
info: dict[str, str] = {
"system": platform.system(),
"release": platform.release(),
"machine": platform.machine(),
"processor": platform.processor(),
"memory_gb": str(round(psutil.virtual_memory().total / (1024**3), 2)),
}
cpu_count = psutil.cpu_count(logical=True)
if cpu_count is None:
info["cpu_count"] = "-1"
else:
info["cpu_count"] = str(cpu_count)
try:
cpu_model = subprocess.check_output(
["sysctl", "-n", "machdep.cpu.brand_string"]
).decode().strip()
info["cpu_model"] = cpu_model
except Exception:
info["cpu_model"] = "Unknown"
return json.dumps(info, indent=4)
if __name__ == '__main__':
print(get_host_info())
source & further reading
gist.github.com — original article
A command file for use with AI coding harness, to automate creation of structured changelog entries.
Session 11 Cheat Sheet — Claude Code & the Claude Agent SDK
Prompt Replit para Aplicação Web Lista de Links