create_knowledge_base
Create a new knowledge base in ServiceNow with customizable title, description, owner, managers, and workflows for publication and retirement processes.
Instructions
Create a new knowledge base in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Description of the knowledge base | |
| managers | No | Users who can manage this knowledge base | |
| owner | No | The specified admin user or group | |
| publish_workflow | No | Publication workflow | Knowledge - Instant Publish |
| retire_workflow | No | Retirement workflow | Knowledge - Instant Retire |
| title | Yes | Title of the knowledge base |
Implementation Reference
- The core handler function that executes the tool logic: constructs data from params, POSTs to /table/kb_knowledge_base API endpoint, handles response or error.def create_knowledge_base( config: ServerConfig, auth_manager: AuthManager, params: CreateKnowledgeBaseParams, ) -> KnowledgeBaseResponse: """ Create a new knowledge base in ServiceNow. Args: config: Server configuration. auth_manager: Authentication manager. params: Parameters for creating the knowledge base. Returns: Response with the created knowledge base details. """ api_url = f"{config.api_url}/table/kb_knowledge_base" # Build request data data = { "title": params.title, } if params.description: data["description"] = params.description if params.owner: data["owner"] = params.owner if params.managers: data["kb_managers"] = params.managers if params.publish_workflow: data["workflow_publish"] = params.publish_workflow if params.retire_workflow: data["workflow_retire"] = params.retire_workflow # Make request try: response = requests.post( api_url, json=data, headers=auth_manager.get_headers(), timeout=config.timeout, ) response.raise_for_status() result = response.json().get("result", {}) return KnowledgeBaseResponse( success=True, message="Knowledge base created successfully", kb_id=result.get("sys_id"), kb_name=result.get("title"), ) except requests.RequestException as e: logger.error(f"Failed to create knowledge base: {e}") return KnowledgeBaseResponse( success=False, message=f"Failed to create knowledge base: {str(e)}", )
- Pydantic model defining the input parameters and validation for the create_knowledge_base tool.class CreateKnowledgeBaseParams(BaseModel): """Parameters for creating a knowledge base.""" title: str = Field(..., description="Title of the knowledge base") description: Optional[str] = Field(None, description="Description of the knowledge base") owner: Optional[str] = Field(None, description="The specified admin user or group") managers: Optional[str] = Field(None, description="Users who can manage this knowledge base") publish_workflow: Optional[str] = Field("Knowledge - Instant Publish", description="Publication workflow") retire_workflow: Optional[str] = Field("Knowledge - Instant Retire", description="Retirement workflow")
- src/servicenow_mcp/utils/tool_utils.py:661-667 (registration)Tool registration entry in get_tool_definitions() dict, mapping name to (handler, schema, return_type, description, serialization)."create_knowledge_base": ( create_knowledge_base_tool, CreateKnowledgeBaseParams, str, # Expects JSON string "Create a new knowledge base in ServiceNow", "json_dict", # Tool returns Pydantic model ),
- src/servicenow_mcp/tools/__init__.py:49-59 (registration)Import of the create_knowledge_base handler into the tools package __init__, exposing it for use.from servicenow_mcp.tools.knowledge_base import ( create_article, create_category, create_knowledge_base, get_article, list_articles, list_knowledge_bases, publish_article, update_article, list_categories, )
- Import aliasing the handler as create_knowledge_base_tool for use in tool registration.# create_category aliased in function call create_knowledge_base as create_knowledge_base_tool, )