Spaces:
Sleeping
Sleeping
A basic server and tools to test it.
Browse files- .idea/drift-detector.iml +4 -2
- .idea/misc.xml +4 -1
- agent.py +22 -0
- app.py +0 -0
- fastagent.config.yaml +11 -0
- server.py +58 -0
.idea/drift-detector.iml
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<module type="PYTHON_MODULE" version="4">
|
| 3 |
<component name="NewModuleRootManager">
|
| 4 |
-
<content url="file://$MODULE_DIR$"
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
<orderEntry type="sourceFolder" forTests="false" />
|
| 7 |
</component>
|
| 8 |
</module>
|
|
|
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<module type="PYTHON_MODULE" version="4">
|
| 3 |
<component name="NewModuleRootManager">
|
| 4 |
+
<content url="file://$MODULE_DIR$">
|
| 5 |
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
| 6 |
+
</content>
|
| 7 |
+
<orderEntry type="jdk" jdkName="Python 3.10 (drift-detector)" jdkType="Python SDK" />
|
| 8 |
<orderEntry type="sourceFolder" forTests="false" />
|
| 9 |
</component>
|
| 10 |
</module>
|
.idea/misc.xml
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<project version="4">
|
| 3 |
-
<component name="
|
|
|
|
|
|
|
|
|
|
| 4 |
</project>
|
|
|
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<project version="4">
|
| 3 |
+
<component name="Black">
|
| 4 |
+
<option name="sdkName" value="Python 3.10 (MCP-exp)" />
|
| 5 |
+
</component>
|
| 6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (drift-detector)" project-jdk-type="Python SDK" />
|
| 7 |
</project>
|
agent.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# agent.py
|
| 2 |
+
import asyncio
|
| 3 |
+
from mcp_agent.core.fastagent import FastAgent
|
| 4 |
+
from mcp_agent.core.prompt import Prompt
|
| 5 |
+
|
| 6 |
+
fast = FastAgent("Drift Test Agent")
|
| 7 |
+
|
| 8 |
+
@fast.agent(
|
| 9 |
+
name="diagnostics",
|
| 10 |
+
instruction="Answer diagnostic questions to test LLM stability.",
|
| 11 |
+
servers=["drift-server"]
|
| 12 |
+
)
|
| 13 |
+
async def main():
|
| 14 |
+
async with fast.run() as agent:
|
| 15 |
+
# Apply prompt from the MCP server
|
| 16 |
+
print(">> Getting prompt from MCP server…")
|
| 17 |
+
result = await agent.apply_prompt("drift-diagnostics")
|
| 18 |
+
print(">> Response:")
|
| 19 |
+
print(result)
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
asyncio.run(main())
|
app.py
ADDED
|
File without changes
|
fastagent.config.yaml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mcp:
|
| 2 |
+
servers:
|
| 3 |
+
drift-server:
|
| 4 |
+
transport: stdio
|
| 5 |
+
command: "python"
|
| 6 |
+
args: ["server.py"]
|
| 7 |
+
|
| 8 |
+
default_model: "generic.llama3.1"
|
| 9 |
+
generic:
|
| 10 |
+
api_key: "ollama" # doesn't matter, just a placeholder
|
| 11 |
+
base_url: "http://localhost:11434/v1"
|
server.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# main.py
|
| 2 |
+
import asyncio
|
| 3 |
+
from mcp.server import Server
|
| 4 |
+
from mcp.server.stdio import stdio_server
|
| 5 |
+
import mcp.types as types
|
| 6 |
+
|
| 7 |
+
# Define diagnostic prompts statically for now
|
| 8 |
+
PROMPTS = {
|
| 9 |
+
"drift-diagnostics": types.Prompt(
|
| 10 |
+
name="drift-diagnostics",
|
| 11 |
+
description="Run a diagnostic questionnaire to test LLM consistency.",
|
| 12 |
+
arguments=[],
|
| 13 |
+
)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
# Setup server
|
| 17 |
+
app = Server("mcp-drift-server", version="0.1.0")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
@app.list_prompts()
|
| 21 |
+
async def list_prompts() -> list[types.Prompt]:
|
| 22 |
+
return list(PROMPTS.values())
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@app.get_prompt()
|
| 26 |
+
async def get_prompt(name: str, arguments: dict[str, str] | None = None) -> types.GetPromptResult:
|
| 27 |
+
if name not in PROMPTS:
|
| 28 |
+
raise ValueError(f"Prompt not found: {name}")
|
| 29 |
+
|
| 30 |
+
# Static message for MVP – replace with dynamic question set later
|
| 31 |
+
return types.GetPromptResult(
|
| 32 |
+
messages=[
|
| 33 |
+
types.PromptMessage(
|
| 34 |
+
role="user",
|
| 35 |
+
content=types.TextContent(
|
| 36 |
+
type="text",
|
| 37 |
+
text="Answer the following: What's the capital of France?"
|
| 38 |
+
)
|
| 39 |
+
),
|
| 40 |
+
types.PromptMessage(
|
| 41 |
+
role="user",
|
| 42 |
+
content=types.TextContent(
|
| 43 |
+
type="text",
|
| 44 |
+
text="Explain why the sky is blue."
|
| 45 |
+
)
|
| 46 |
+
),
|
| 47 |
+
]
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# Main entrypoint
|
| 52 |
+
async def main():
|
| 53 |
+
async with stdio_server() as streams:
|
| 54 |
+
await app.run(streams[0], streams[1], app.create_initialization_options())
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
asyncio.run(main())
|