Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Myasoedov 1217eecdbd Refine getting started guide 2025-06-20 20:34:13 +03:00
9 changed files with 2942 additions and 2911 deletions
+29 -43
View File
@@ -3,8 +3,6 @@ import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from agentic_security.logutils import logger
# Create server parameters for stdio connection
server_params = StdioServerParameters(
command="python", # Executable
@@ -14,54 +12,42 @@ server_params = StdioServerParameters(
async def run() -> None:
try:
logger.info(
"Starting stdio client session with server parameters: %s", server_params
)
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()
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# Initialize the connection --> connection does not work
await session.initialize()
# List available prompts, resources, and tools --> no avalialbe tools
logger.info("Listing available prompts...")
prompts = await session.list_prompts()
logger.info(f"Available prompts: {prompts}")
# List available prompts, resources, and tools --> no avalialbe tools
prompts = await session.list_prompts()
print(f"Available prompts: {prompts}")
logger.info("Listing available resources...")
resources = await session.list_resources()
logger.info(f"Available resources: {resources}")
resources = await session.list_resources()
print(f"Available resources: {resources}")
logger.info("Listing available tools...")
tools = await session.list_tools()
logger.info(f"Available tools: {tools}")
tools = await session.list_tools()
print(f"Available tools: {tools}")
# Call the echo tool --> echo tool issue
logger.info("Calling echo_tool with message...")
echo_result = await session.call_tool(
"echo_tool", arguments={"message": "Hello from client!"}
)
logger.info(f"Tool result: {echo_result}")
# Call the echo tool --> echo tool iisue
echo_result = await session.call_tool(
"echo_tool", arguments={"message": "Hello from client!"}
)
print(f"Tool result: {echo_result}")
# # Read the echo resource
# echo_content, mime_type = await session.read_resource(
# "echo://Hello_resource"
# )
# logger.info(f"Resource content: {echo_content}")
# logger.info(f"Resource MIME type: {mime_type}")
# # Read the echo resource
# echo_content, mime_type = await session.read_resource(
# "echo://Hello_resource"
# )
# print(f"Resource content: {echo_content}")
# print(f"Resource MIME type: {mime_type}")
# # Get and use the echo prompt
# prompt_result = await session.get_prompt(
# "echo_prompt", arguments={"message": "Hello prompt!"}
# )
# logger.info(f"Prompt result: {prompt_result}")
# # Get and use the echo prompt
# prompt_result = await session.get_prompt(
# "echo_prompt", arguments={"message": "Hello prompt!"}
# )
# print(f"Prompt result: {prompt_result}")
logger.info("Client operations completed successfully.")
return prompts, resources, tools
except Exception as e:
logger.error(f"An error occurred during client operations: {e}", exc_info=True)
raise
# You can perform additional operations here as needed
return prompts, resources, tools
if __name__ == "__main__":
+1
View File
@@ -4,6 +4,7 @@ from mcp.server.fastmcp import FastMCP
# Initialize MCP server
mcp = FastMCP(
name="Agentic Security MCP Server",
description="MCP server to interact with LLM scanning test",
dependencies=["httpx"],
)
+1 -1
View File
@@ -8,6 +8,7 @@ from typing import Any, TypeVar
import httpx
import pandas as pd
from cache_to_disk import cache_to_disk
from datasets import load_dataset
from agentic_security.logutils import logger
from agentic_security.probe_data import stenography_fn
@@ -19,7 +20,6 @@ from agentic_security.probe_data.modules import (
inspect_ai_tool,
rl_model,
)
from datasets import load_dataset
# Type aliases for clarity
T = TypeVar("T")
+36 -5
View File
@@ -1,23 +1,54 @@
# Getting Started
Welcome to Agentic Security! This guide will help you get started with using the tool.
Welcome to Agentic Security! This guide will help you orient yourself within the project and start using the tool quickly.
## Project Overview
Agentic Security is an open-source vulnerability scanner for Large Language Models (LLMs). It provides both a command line interface and a FastAPI server so you can probe models for weaknesses such as jailbreaks or refusal patterns. The tool supports multimodal attacks, multi-step scans and reinforcement-learning based probes.
## Repository Layout
```
agentic_security/
├── __main__.py - CLI entry point
├── app.py - FastAPI app assembly
├── lib.py - SecurityScanner and utilities
├── config.py - Configuration handling
├── core/ - app state and logging helpers
├── probe_actor/ - scanning logic and RL modules
├── probe_data/ - dataset registry and loaders
├── routes/ - API endpoints
└── ui/ - Web UI assets (Vue)
```
`tests/` contains unit tests, and `docs/` houses the project documentation.
## Quick Start
1. Ensure you have completed the [installation](installation.md) steps.
1. Run the following command to start the application:
2. Run the following command to start the application:
```bash
agentic_security
```
1. Access the application at `http://localhost:8718`.
The server will start on `http://localhost:8718`.
3. Explore available commands with:
```bash
agentic_security --help
```
## Basic Usage
- To view available commands, use:
- To view available commands, run:
```bash
agentic_security --help
```
## Next Steps
Explore the [Configuration](configuration.md) section to customize your setup.
- Review the [Quickstart Guide](quickstart.md) for a fast setup walkthrough.
- Check [http_spec.md](http_spec.md) to learn how LLM endpoints are described.
- Browse the `probe_actor` and `probe_data` modules to understand how scanning works and how datasets are loaded.
- Explore the [Configuration](configuration.md) section to customize your setup.
- Run the tests in `tests/` to verify your environment once dependencies are installed.
This guide should give you a solid foundation for exploring and extending Agentic Security. For more details, see the rest of the documentation.
Generated
+2253 -2375
View File
File diff suppressed because it is too large Load Diff
+26 -22
View File
@@ -28,50 +28,54 @@ agentic_security = "agentic_security.__main__:main"
[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.116.1"
uvicorn = "^0.35.0"
fastapi = "^0.115.8"
uvicorn = "^0.34.0"
fire = "0.7.0"
loguru = "^0.7.3"
httpx = "^0.28.1"
cache-to-disk = "^2.0.0"
pandas = ">=1.4,<3.0"
datasets = "^4.0.0"
datasets = "^3.3.0"
tabulate = ">=0.8.9,<0.10.0"
colorama = "^0.4.4"
matplotlib = "^3.10.5"
pydantic = "^2.11.7"
matplotlib = "^3.9.2"
pydantic = "2.10.6"
scikit-optimize = "^0.10.2"
scikit-learn = "^1.7.1"
scikit-learn = "1.6.1"
numpy = ">=1.24.3,<3.0.0"
jinja2 = "^3.1.4"
python-multipart = "^0.0.20"
tomli = "^2.2.1"
rich = "^14.1.0"
rich = "13.9.4"
gTTS = "^2.5.4"
sentry_sdk = "^2.34.1"
orjson = "^3.11.2"
pyfiglet = "^1.0.3"
termcolor = "^3.1.0"
mcp = "^1.12.4"
sentry_sdk = "^2.22.0"
orjson = "^3.10"
pyfiglet = "^1.0.2"
termcolor = "^2.4.0"
mcp = "^1.4.1"
# garak = { version = "*", optional = true }
pytest-xdist = "^3.8.0"
pytest-xdist = "3.6.1"
[tool.poetry.group.dev.dependencies]
# Pytest
pytest = "^8.4.1"
pytest-asyncio = "^1.1.0"
inline-snapshot = ">=0.13.3,<0.27.2"
pytest = "^8.3.4"
pytest-asyncio = "^0.25.2"
inline-snapshot = ">=0.13.3,<0.21.0"
pytest-httpx = "^0.35.0"
pytest-mock = "^3.14.1"
pytest-mock = "^3.14.0"
# Rest
black = ">=24.10,<26.0"
mypy = "^1.17.1"
pre-commit = "^4.3.0"
huggingface-hub = ">=0.25.1,<0.34.4"
mypy = "^1.12.0"
pre-commit = "^4.0.1"
huggingface-hub = ">=0.25.1,<0.30.0"
# Docs
mkdocs = ">=1.4.2"
mkdocs-material = "^9.6.16"
mkdocstrings = ">=0.29.0"
mkdocs-material = "^9.6.4"
mkdocstrings = ">=0.26.1"
mkdocs-jupyter = ">=0.25.1"
+1 -1
View File
@@ -1,7 +1,7 @@
import pytest
from datasets import load_dataset
from agentic_security.probe_data import REGISTRY
from datasets import load_dataset
@pytest.mark.slow
+594 -463
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -19,7 +19,7 @@
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^9.39.1",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {