create_knowledge_base
Create a new knowledge base in ServiceNow to organize and manage articles, documentation, and support resources for internal or external users.
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 implements the logic to create a knowledge base by making a POST request to the ServiceNow kb_knowledge_base table API.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:707-713 (registration)Registration of the 'create_knowledge_base' tool in the central tool definitions dictionary used by the MCP server, specifying the handler function, input schema, return type, description, and serialization method."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:52-52 (registration)Import and exposure of the create_knowledge_base function in the tools package __init__.py for easy access.create_knowledge_base,