mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-06-28 16:19:58 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b5425c14b | |||
| c45778f196 | |||
| a5bdbe54a2 | |||
| 61da912f18 | |||
| a02aed2c2b | |||
| 40ff7f9dfb | |||
| c09ce32def | |||
| c5406e8a0e | |||
| b260672b1a |
@@ -3,6 +3,8 @@ import asyncio
|
|||||||
from mcp import ClientSession, StdioServerParameters
|
from mcp import ClientSession, StdioServerParameters
|
||||||
from mcp.client.stdio import stdio_client
|
from mcp.client.stdio import stdio_client
|
||||||
|
|
||||||
|
from agentic_security.logutils import logger
|
||||||
|
|
||||||
# Create server parameters for stdio connection
|
# Create server parameters for stdio connection
|
||||||
server_params = StdioServerParameters(
|
server_params = StdioServerParameters(
|
||||||
command="python", # Executable
|
command="python", # Executable
|
||||||
@@ -12,42 +14,54 @@ server_params = StdioServerParameters(
|
|||||||
|
|
||||||
|
|
||||||
async def run() -> None:
|
async def run() -> None:
|
||||||
async with stdio_client(server_params) as (read, write):
|
try:
|
||||||
async with ClientSession(read, write) as session:
|
logger.info(
|
||||||
# Initialize the connection --> connection does not work
|
"Starting stdio client session with server parameters: %s", server_params
|
||||||
await session.initialize()
|
)
|
||||||
|
async with stdio_client(server_params) as (read, write):
|
||||||
|
async with ClientSession(read, write) as session:
|
||||||
|
# Initialize the connection --> connection does not work
|
||||||
|
logger.info("Initializing client session...")
|
||||||
|
await session.initialize()
|
||||||
|
|
||||||
# List available prompts, resources, and tools --> no avalialbe tools
|
# List available prompts, resources, and tools --> no avalialbe tools
|
||||||
prompts = await session.list_prompts()
|
logger.info("Listing available prompts...")
|
||||||
print(f"Available prompts: {prompts}")
|
prompts = await session.list_prompts()
|
||||||
|
logger.info(f"Available prompts: {prompts}")
|
||||||
|
|
||||||
resources = await session.list_resources()
|
logger.info("Listing available resources...")
|
||||||
print(f"Available resources: {resources}")
|
resources = await session.list_resources()
|
||||||
|
logger.info(f"Available resources: {resources}")
|
||||||
|
|
||||||
tools = await session.list_tools()
|
logger.info("Listing available tools...")
|
||||||
print(f"Available tools: {tools}")
|
tools = await session.list_tools()
|
||||||
|
logger.info(f"Available tools: {tools}")
|
||||||
|
|
||||||
# Call the echo tool --> echo tool iisue
|
# Call the echo tool --> echo tool issue
|
||||||
echo_result = await session.call_tool(
|
logger.info("Calling echo_tool with message...")
|
||||||
"echo_tool", arguments={"message": "Hello from client!"}
|
echo_result = await session.call_tool(
|
||||||
)
|
"echo_tool", arguments={"message": "Hello from client!"}
|
||||||
print(f"Tool result: {echo_result}")
|
)
|
||||||
|
logger.info(f"Tool result: {echo_result}")
|
||||||
|
|
||||||
# # Read the echo resource
|
# # Read the echo resource
|
||||||
# echo_content, mime_type = await session.read_resource(
|
# echo_content, mime_type = await session.read_resource(
|
||||||
# "echo://Hello_resource"
|
# "echo://Hello_resource"
|
||||||
# )
|
# )
|
||||||
# print(f"Resource content: {echo_content}")
|
# logger.info(f"Resource content: {echo_content}")
|
||||||
# print(f"Resource MIME type: {mime_type}")
|
# logger.info(f"Resource MIME type: {mime_type}")
|
||||||
|
|
||||||
# # Get and use the echo prompt
|
# # Get and use the echo prompt
|
||||||
# prompt_result = await session.get_prompt(
|
# prompt_result = await session.get_prompt(
|
||||||
# "echo_prompt", arguments={"message": "Hello prompt!"}
|
# "echo_prompt", arguments={"message": "Hello prompt!"}
|
||||||
# )
|
# )
|
||||||
# print(f"Prompt result: {prompt_result}")
|
# logger.info(f"Prompt result: {prompt_result}")
|
||||||
|
|
||||||
# You can perform additional operations here as needed
|
logger.info("Client operations completed successfully.")
|
||||||
return prompts, resources, tools
|
return prompts, resources, tools
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"An error occurred during client operations: {e}", exc_info=True)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from mcp.server.fastmcp import FastMCP
|
|||||||
# Initialize MCP server
|
# Initialize MCP server
|
||||||
mcp = FastMCP(
|
mcp = FastMCP(
|
||||||
name="Agentic Security MCP Server",
|
name="Agentic Security MCP Server",
|
||||||
description="MCP server to interact with LLM scanning test",
|
|
||||||
dependencies=["httpx"],
|
dependencies=["httpx"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from typing import Any, TypeVar
|
|||||||
import httpx
|
import httpx
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from cache_to_disk import cache_to_disk
|
from cache_to_disk import cache_to_disk
|
||||||
from datasets import load_dataset
|
|
||||||
|
|
||||||
from agentic_security.logutils import logger
|
from agentic_security.logutils import logger
|
||||||
from agentic_security.probe_data import stenography_fn
|
from agentic_security.probe_data import stenography_fn
|
||||||
@@ -20,6 +19,7 @@ from agentic_security.probe_data.modules import (
|
|||||||
inspect_ai_tool,
|
inspect_ai_tool,
|
||||||
rl_model,
|
rl_model,
|
||||||
)
|
)
|
||||||
|
from datasets import load_dataset
|
||||||
|
|
||||||
# Type aliases for clarity
|
# Type aliases for clarity
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|||||||
Generated
+2371
-2076
File diff suppressed because it is too large
Load Diff
+22
-26
@@ -28,54 +28,50 @@ agentic_security = "agentic_security.__main__:main"
|
|||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
fastapi = "^0.115.8"
|
fastapi = "^0.116.1"
|
||||||
uvicorn = "^0.34.0"
|
uvicorn = "^0.35.0"
|
||||||
fire = "0.7.0"
|
fire = "0.7.0"
|
||||||
loguru = "^0.7.3"
|
loguru = "^0.7.3"
|
||||||
httpx = "^0.28.1"
|
httpx = "^0.28.1"
|
||||||
cache-to-disk = "^2.0.0"
|
cache-to-disk = "^2.0.0"
|
||||||
pandas = ">=1.4,<3.0"
|
pandas = ">=1.4,<3.0"
|
||||||
datasets = "^3.3.0"
|
datasets = "^4.0.0"
|
||||||
tabulate = ">=0.8.9,<0.10.0"
|
tabulate = ">=0.8.9,<0.10.0"
|
||||||
colorama = "^0.4.4"
|
colorama = "^0.4.4"
|
||||||
matplotlib = "^3.9.2"
|
matplotlib = "^3.10.5"
|
||||||
pydantic = "2.10.6"
|
pydantic = "^2.11.7"
|
||||||
scikit-optimize = "^0.10.2"
|
scikit-optimize = "^0.10.2"
|
||||||
scikit-learn = "1.6.1"
|
scikit-learn = "^1.7.1"
|
||||||
numpy = ">=1.24.3,<3.0.0"
|
numpy = ">=1.24.3,<3.0.0"
|
||||||
jinja2 = "^3.1.4"
|
jinja2 = "^3.1.4"
|
||||||
python-multipart = "^0.0.20"
|
python-multipart = "^0.0.20"
|
||||||
tomli = "^2.2.1"
|
tomli = "^2.2.1"
|
||||||
rich = "13.9.4"
|
rich = "^14.1.0"
|
||||||
gTTS = "^2.5.4"
|
gTTS = "^2.5.4"
|
||||||
sentry_sdk = "^2.22.0"
|
sentry_sdk = "^2.34.1"
|
||||||
orjson = "^3.10"
|
orjson = "^3.11.2"
|
||||||
pyfiglet = "^1.0.2"
|
pyfiglet = "^1.0.3"
|
||||||
termcolor = "^2.4.0"
|
termcolor = "^3.1.0"
|
||||||
mcp = "^1.4.1"
|
mcp = "^1.12.4"
|
||||||
|
|
||||||
# garak = { version = "*", optional = true }
|
# garak = { version = "*", optional = true }
|
||||||
pytest-xdist = "3.6.1"
|
pytest-xdist = "^3.8.0"
|
||||||
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
# Pytest
|
# Pytest
|
||||||
pytest = "^8.3.4"
|
pytest = "^8.4.1"
|
||||||
pytest-asyncio = "^0.25.2"
|
pytest-asyncio = "^1.1.0"
|
||||||
inline-snapshot = ">=0.13.3,<0.21.0"
|
inline-snapshot = ">=0.13.3,<0.31.1"
|
||||||
pytest-httpx = "^0.35.0"
|
pytest-httpx = "^0.35.0"
|
||||||
pytest-mock = "^3.14.0"
|
pytest-mock = "^3.14.1"
|
||||||
|
|
||||||
# Rest
|
# Rest
|
||||||
black = ">=24.10,<26.0"
|
black = ">=24.10,<26.0"
|
||||||
mypy = "^1.12.0"
|
mypy = "^1.17.1"
|
||||||
pre-commit = "^4.0.1"
|
pre-commit = "^4.3.0"
|
||||||
huggingface-hub = ">=0.25.1,<0.30.0"
|
huggingface-hub = ">=0.25.1,<0.34.4"
|
||||||
|
|
||||||
# Docs
|
# Docs
|
||||||
mkdocs = ">=1.4.2"
|
mkdocs = ">=1.4.2"
|
||||||
mkdocs-material = "^9.6.4"
|
mkdocs-material = "^9.6.16"
|
||||||
mkdocstrings = ">=0.26.1"
|
mkdocstrings = ">=0.29.0"
|
||||||
mkdocs-jupyter = ">=0.25.1"
|
mkdocs-jupyter = ">=0.25.1"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from datasets import load_dataset
|
|
||||||
|
|
||||||
from agentic_security.probe_data import REGISTRY
|
from agentic_security.probe_data import REGISTRY
|
||||||
|
from datasets import load_dataset
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
|
|||||||
Generated
+7
-7
@@ -4266,9 +4266,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/compression": {
|
"node_modules/compression": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/compression/-/compression-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/compression/-/compression-1.8.1.tgz",
|
||||||
"integrity": "sha512-k6WLKfunuqCYD3t6AsuPGvQWaKwuLLh2/xHNcX4qE+vIfDNXpSqnrhwA7O53R7WVQUnt8dVAIW+YHr7xTgOgGA==",
|
"integrity": "sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4276,7 +4276,7 @@
|
|||||||
"compressible": "~2.0.18",
|
"compressible": "~2.0.18",
|
||||||
"debug": "2.6.9",
|
"debug": "2.6.9",
|
||||||
"negotiator": "~0.6.4",
|
"negotiator": "~0.6.4",
|
||||||
"on-headers": "~1.0.2",
|
"on-headers": "~1.1.0",
|
||||||
"safe-buffer": "5.2.1",
|
"safe-buffer": "5.2.1",
|
||||||
"vary": "~1.1.2"
|
"vary": "~1.1.2"
|
||||||
},
|
},
|
||||||
@@ -8419,9 +8419,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/on-headers": {
|
"node_modules/on-headers": {
|
||||||
"version": "1.0.2",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz",
|
||||||
"integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==",
|
"integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
Reference in New Issue
Block a user